Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm setting up my first virtual host but the domain is not working. I've sudo a2ensite SITENAME'd it and restarted apache but it's still not accessible. I've verified that the IP is correct because I'm currently logged into splunk via the IP.


I have my NameVirtualHost *:80 on apache2.conf. My updated VirtualHost configuration for the site is:


        DocumentRoot /home/source/public_html/
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        <Directory /home/source/public_html/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all

        ErrorLog /home/source/log/error_log
        TransferLog /home/source/log/access_log

I have also updated /etc/hosts to show:       localhost       productionserver
share|improve this question
up vote 2 down vote accepted

What version of Apache are you using? If you are using version 2, the default VirtualHost configuration should serve you well. Use the following command to create a new VirtualHost:

$ sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/ 

Edit directives using your favourite text editor:

$ gksudo gedit /etc/apache2/sites-available/

Activate your site:

$ sudo a2ensite

Reload Apache:

$ sudo /etc/init.d/apache2 reload

Update /etc/hosts file with IP address and domain name:

Browse to

Hope this helps!


share|improve this answer
Thanks for the tips, a few steps you mentioned I had forgotten, but I'm still not able to access the site. – Webnet Aug 20 '10 at 16:40
NameVirtualHost *:80

Better yet, just use *:80 in the VirtualHost directive if you don't need (or care) to tie it to a specific IP address.

NameVirtualHost *:80
<VirtualHost *:80>
share|improve this answer
PS: it's common syntax that 'ServerName' should always be the first line inside the VirtualHost block for clarity. It's not a technical thing, but a human readable thing. – troyengel Aug 20 '10 at 0:55
Also, use tail on apache's log files when making request. – peelman Aug 20 '10 at 4:34
I'd prefer to stick with the IP address – Webnet Aug 20 '10 at 18:18

You only have in your hosts file and the server name is

You can fix it by either adding after in your hosts file or adding this line after ServerName directive in apache configuration:


Then reload apache configuration.

Thanks, -Kamil

share|improve this answer
I made that adjustment and reloaded apache, it didn't appear to have any effect. – Webnet Aug 20 '10 at 17:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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