I just installed Apache 2.2, and am trying to have two domains hosted on the same server configuration. I first created a Virtual Host (a.com), and debugged my configuration so that it was working. When I tried to add virtual host b.com, and tried to access it, all I get is the correct page for a.com. Both Virtual Hosts are pointed to the same static IP address. The server is running CentOS on a VPS.
/usr/local/apache2/conf/httpd.conf has the basic configuration, and is partly included below, but I have
Include a second file,
clients.conf that in turn
Includes per-site configuration, which is in the home directories of the different websites. (Each site has their own account, with directories
Listen 80 NameVirtualHost [ip] # [...] Include /usr/local/apache2/conf/clients.conf
Include /home/[a]/conf/apache/vhost.conf Include /home/[b]/conf/apache/vhost.conf
<VirtualHost [ip]> ServerName www.[a].com ServerAlias [a].com ServerAdmin [me]@[a].com DocumentRoot /home/[a]/web/home ErrorDocument 404 "http://www.[a].com/error/?404" <Directory /home/[a]/web/home> Options -Indexes FollowSymLinks # Don't allow any .htaccess files AllowOverride None # Allow everyone to access Order allow,deny </Directory> </VirtualHost>
<VirtualHost [ip]> ServerName www.[b].com ServerAlias [b].com ServerAdmin admin@[b].com DocumentRoot /home/[b]/web/home ErrorDocument 404 "http://www.[b].com/error/?/404/" <Directory /home/[b]/web/home> Options -Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> </VirtualHost> <VirtualHost [ip]> ServerName beta.[b].com DocumentRoot /home/[b]/web/home <Directory /home/[b]/web/home> Options -Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> </VirtualHost>
(Sorry for all the code, but I didn't know how much was needed.)
Might anyone see a problem in my code? I think that it looks almost identical to the VirtualHost Example (first one), except that I have expanded the "Other directives here" and have used full IP addresses, rather than the
* wildcard, which is described in the "Note:" below the example.
As suggested by a comment, I tried
apachectl -S, which gave the following output:
# /usr/local/apache2/bin/apachectl -S VirtualHost configuration: [ip] is a NameVirtualHost default server www.[a].com (/home/[a]/conf/apache/vhost.conf:5) port 80 namevhost www.[a].com (/home/[a]/conf/apache/vhost.conf:5) Syntax OK
[b].com be showing up here?