My apache2 virtual host is not working. And I've totally no idea on what the error is.

What happended?

I've one virtual host named v1, and it works fine. Then I copied sites-available/v1 to sites-avaliable/v2 and changed the v2's content. After that a a2ensite and service apache2 restart is performed.

The error

Oops! Google Chrome could not find pie.example.com

and empty error log in /var/log/XXX.log



<VirtualHost *:80>
ServerName sym.example.com
ServerAdmin sym@mail.example.com
DocumentRoot "/var/www/symphony/symphony-2"
ErrorLog "/var/log/apache2/symphony_errors.log"
CustomLog "/var/log/apache2/symphony_accesses.log" common    


<VirtualHost *:80>
ServerName pie.example.com
ServerAdmin pie@mail.example.com
DocumentRoot "/var/www/sf2piemoment"
ErrorLog "/var/log/apache2/piemoment_errors.log"
CustomLog "/var/log/apache2/piemoment_accesses.log" common    

hosts example.com


Any ideas and suggestions? I'm totally confused on this. Please help me on this. P.S. I'm pretty new to linux...

  • Are you sure your DNS is set? Unless you have no default site, when vhosts dont work you generally get taken to the wrong site (default), and not given that sort of error. – David Houde Jun 16 '13 at 12:38
  • @DavidHoude I added a hosts entry. Plz see the update. Terribly sorry for wasting your time. – SolessChong Jun 16 '13 at 13:39

The error "could not find pie.example.com" means that the address pie.example.com can't be resolved in DNS. Since there is no DNS answer, your browser doesn't know that it should ask your apache for the site, and that is why there is nothing in your apache logs.

So step one is to fix your DNS settings so that the domain actually resolves. After that, if there are still problems, you can ask about those problems.

As you are using a hosts file instead of a DNS entry, you can simply add more names to the line in /etc/hosts: localhost example.com sym.example.com pie.example.com

all on the same line.

  • I added a hosts entry. Please see the update. Sorry for leaving this out. and terribly sorry for wasting your time. – SolessChong Jun 16 '13 at 13:37
  • Your hosts file does not contain sym.example.com, it only contains example.com. You need to actually write out the entire host name for each host; it doesn't do wildcards. – Jenny D Jun 16 '13 at 16:36
  • Oh, and thanks a lot for apologizing, I really appreciate it! I wish more people would act the way you do here! – Jenny D Jun 16 '13 at 16:37
  • I'm afraid there could be more problem since sym.example.com works but pie.example.com doesn't – SolessChong Jun 16 '13 at 17:47
  • Still, the answer remains that this is not an apache error. Could you try adding pie.example.com to the hosts file, too? I'm adding a line to explain how to do that. – Jenny D Jun 16 '13 at 18:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.