Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 keep adding more vhosts and enabling them but all the sites always do to the default vhost in sites-available

here is what the default kind of looks like with me only changing the ip for security reasons

 <VirtualHost 167.889.88.88:80>
     ServerAdmin webmaster@localhost

     DocumentRoot /var/www
     <Directory />
             Options FollowSymLinks
             AllowOverride None
     <Directory /var/www/>
             Options Indexes FollowSymLinks MultiViews
             AllowOverride None
             Order allow,deny
             allow from all

     ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
     <Directory "/usr/lib/cgi-bin">
             AllowOverride None
             Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
             Order allow,deny
             Allow from all

     ErrorLog /var/log/apache2/error.log

     # Possible values include: debug, info, notice, warn, error, crit,
     # alert, emerg.
     LogLevel warn

     CustomLog /var/log/apache2/access.log combined

 Alias /doc/ "/usr/share/doc/"
 <Directory "/usr/share/doc/">
     Options Indexes MultiViews FollowSymLinks
     AllowOverride None
     Order deny,allow
     Deny from all
     Allow from ::1/128


and here is my other which i named

 <VirtualHost *:80>
     DocumentRoot "/var/www/vhosts/"

     <Directory "/var/www/vhosts/">
             AllowOverride all
             Options -MultiViews

and it turned on my this command

sudo a2ensite
 Enabling site
 Run '/etc/init.d/apache2 reload' to activate new configuration!

then i reloaded

/etc/init.d/apache2 reload
* Reloading web server config apache2

but when i visit the url i get the index page that is for the default vhost...what am i doing wrong

share|improve this question
Maybe something is missing from the configuration you've posted here, but I don't see any <VirtualHost> blocks. – larsks Jan 26 '11 at 16:13
i changed my blocks to show the correct info – Matt Jan 26 '11 at 16:20
up vote 2 down vote accepted

First guess, you need the NameVirtualHost statement in your httpd.conf file. Also, as a sanity check, I'm assuming you have the correct blocks?

What do you get when you run apachectl -S ?

share|improve this answer
i get apachectl -S bash: apachectl: command not found – Matt Jan 26 '11 at 16:18
look at the virtual hosts now, i changed them to show you the VirtualHost statements – Matt Jan 26 '11 at 16:20
do i actually put the NameVirtualHost in the httpd.conf or in the new vhost file.... – Matt Jan 26 '11 at 16:22
it goes in the main server config (not the vhost or directory blocks) – DTest Jan 26 '11 at 16:33
but what goes there lets say i have 3 sites on the same server do i need 3 NameVirtualHost's – Matt Jan 26 '11 at 16:35

In your first block you do not have a ServerName specified and Apache is matching the incoming request to the IP. The problem is with the mix of IP and Name based virtual server configuration.

To further rule out the problem out a ServerName directive in your virtual server directive which start as follows.

VirtualHost 167.889.88.88:80

share|improve this answer
how do i resolve this issue then – Matt Jan 26 '11 at 16:47
In the first section use the name of the domain which you want to use as default domain incase of any requests that come to the server. Apache defaults to the first Server block when it can't find a matching server block. – Sameer Jan 26 '11 at 16:57

Add following lines in /etc/hosts file:

share|improve this answer

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.