Forum Moderators: phranque

Message Too Old, No Replies

Virtual Host Problems

Virtual Host Apache 2.2

         

ratnamg

12:53 am on Feb 6, 2008 (gmt 0)

10+ Year Member



Hi
I am trying to configure virtual host on apache and I am running into a problem where the server defaults to the default location and cannot get apache to pull from the second server.
- I have configured 2 files in vhosts.d folder
- I have added NameVirtualHost *.80 to the httpd.conf
- I have entries in the /etc/hosts file for the 2 servers

apache2ctl - S results are below
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server www.a.com (/etc/apache2/vhosts.d/01.a.conf:1)
port 80 namevhost www.a.com (/etc/apache2/vhosts.d/01.a.conf:1)
port 80 namevhost www.b.com (/etc/apache2/vhosts.d/02.b.conf:1)
Syntax OK

My first conf file in vhosts.d folder is :
01.a.conf
<VirtualHost *:80>
ServerName www.a.com
DocumentRoot /srv/www/htdocs
ServerAlias a.com www.a.com
ServerAdmin a@a.com
<Directory /srv/www/htdocs>
AllowOverride None
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin/ /srv/www/cgi-bin
<Directory /srv/www/cgi-bin>
AllowOverride None
Options +ExecCGI -Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

File 2
02.b.conf
<VirtualHost *:80>
DocumentRoot /srv/www/htdocs/b
ServerName www.b.com
ServerAlias www.b.info www.b.org b.com
ServerAdmin b@b.com
<Directory /srv/www/htdocs/b>
AllowOverride None
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin/ /srv/www/cgi-bin
<Directory /srv/www/cgi-bin>
AllowOverride None
Options +ExecCGI -Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

lammert

12:17 pm on Feb 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have entries in the /etc/hosts file for the 2 servers

Do you mean you are calling the site locally, or is it accessed from a remote location? For a remote location setting the hostnames /etc/hosts has no effect, you have to add them to a DNS server.

ratnamg

1:53 pm on Feb 7, 2008 (gmt 0)

10+ Year Member



for calling it locally. I have now taken that our and set that up in the DNS Server.