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 some-site.net

 <VirtualHost *:80>
     ServerName some-site.net
     DocumentRoot "/var/www/vhosts/somesite.com/http/"

     <Directory "/var/www/vhosts/somesite.com/http/">
             AllowOverride all
             Options -MultiViews

and it turned on my this command

sudo a2ensite some-site.net
 Enabling site some-site.net.
 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 some-site.net i get the index page that is for the default vhost...what am i doing wrong

  • 1
    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 Elhotiby Jan 26 '11 at 16:20

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 ?

  • i get apachectl -S bash: apachectl: command not found – Matt Elhotiby Jan 26 '11 at 16:18
  • look at the virtual hosts now, i changed them to show you the VirtualHost statements – Matt Elhotiby Jan 26 '11 at 16:20
  • do i actually put the NameVirtualHost in the httpd.conf or in the new vhost file.... – Matt Elhotiby 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 ....so lets say i have 3 sites on the same server do i need 3 NameVirtualHost's – Matt Elhotiby 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

  • how do i resolve this issue then – Matt Elhotiby 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:

localhost some-site.net

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.