I have an Apache2 server setup with several vhosts, and it all works fine. Navigating to my ip renders one of those vhosts (/etc/apache2/sites-enabled/main_site.com
), which--up until now--I had wanted.
Now I want the ip to go to the default vhost /etc/apache2/sites-enabled/default
, but I can't remember where to change that. I assume there's some directive in /etc/apache2/apache2.conf
, but nothing is sticking out at me.
Any help would be appreciated.
➜ /etc/apache2: ls sites-enabled/
default micro_main_1.com micro_main_2.com main.com
sub1.main.com micro_main_3.biz micro_main_4.com main_site.com
sub1.main2.com micro_main_5.biz
➜ /etc/apache2/sites-enabled: cat default
NameVirtualHost *
<VirtualHost *>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
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
ServerSignature Email
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
/etc/apache2/apache2.conf
=> https://gist.github.com/1017147
➜ /etc/apache2/sites-enabled: cat main_site.com
<VirtualHost *:80>
ServerAdmin admin@main_site.com
ServerName main_site.com
ServerAlias www.main_site.com
# ...
</VirtualHost>
You have in your /etc/apache2/apache2.conf:
Move NameVirtualHost before Inlcuding virutal hosts configurations. It should be like following:
Also you don't need the NameVirtualHost * in your default virtual host file.
The first VirtualHost that's loaded with that IP:Port pair will be used to render requests which do not contain a host header. Make sure your virtualhosts clearly use the IP address or *, and the port #. Now, I believe the files in sites-enabled are loaded in alphabetical order, which would mean that the default file should take precedence over the main_site file.
Post your VirtualHost and we can take a look.
You've likely got a
ServerName
orServerAlias
directive that specifies the IP address inmain_site
, or the<VirtualHost>
block specifically specifies the IP to listen on (instead of*:80
; which is probably disabling name-based vhosting completely).If there's no matching
ServerName
orServerAlias
, and the vhosts are all set to a listener specification that matches yourNameVirtualHost
directive, then the first vhost to load (alphabetically) will serve the request. That's not happening, so one of those two things must be off.Put the site that you want to respond per default first in the list.
On Ubuntu/Debian:
(or another site, if you want it to be the default)