Click to See Complete Forum and Search --> : Apache virtual hosts problem


jme
03-14-2004, 04:12 PM
Hiya Guys,

I have finally get my Apache, PHP, MySQL setup running under Debian, and now I want to be able to setup my server t o host two sites. I have read the Apache how-to's and some other sites that I have found through G4L, but I am still having problems.

When I point my browser at www.siteone.com I get what I should be getting - ie. the www.siteone.com homepage, however, if I point my browser at www.sitetwo.com, I still get the homepage of the first site.

Here is my virtual hosts part of my httpd.conf file:

NameVirtualHost 192.168.1.200

<VirtualHost 192.168.1.200>
ServerName www.siteone.com
DocumentRoot /var/www/siteone.com/
ErrorLog /var/www/siteone.com/error.log
</VirtualHost>

<VirtualHost 192.168.1.200>
ServerName www.sitetwo.com
DocumentRoot /var/www/sitetwo/
ErrorLog /var/www/sitetwo/error.log
</VirtualHost>


Any ideas or suggestions as to why this is happening would be great.

Thanks.

Jamie

mdwatts
03-14-2004, 05:02 PM
I searched the JL Networking forum for 'apache virtual host' and besides the previous examples posted in the search results, I also found

http://httpd.apache.org/docs/vhosts/index.html

which should help with the virtual host configuration. Compare your setup to what they have.

Did you restart Apache after modifying httpd.conf?

jme
03-14-2004, 05:37 PM
I'd already had a look at the apache virtual hosts guide and didn't see anything that really jumped out at me as to why I was getting this problem.

One other thing that I didn't mention before was that I am having to use no-ip.com dyndns to be able to use the server as I am on a dynamic ip connection. As a result I have updated the config file so that it now looks like:


NameVirtualHost 192.168.1.200

<VirtualHost 192.168.1.200>
ServerName www.siteone.no-ip.com
DocumentRoot /var/www/siteone.com/
ErrorLog /var/www/siteone.com/error.log
</VirtualHost>

<VirtualHost 192.168.1.200>
ServerName www.sitetwo.no-ip.com
DocumentRoot /var/www/sitetwo.com/
ErrorLog /var/www/sitetwo.com/error.log
</VirtualHost>


Also, I read that I needed to update my /etc/hosts file to contain the following:

/etc/hosts
127.0.0.1 localhost
192.168.1.200 prelude
192.168.1.200 www.siteone.no-ip.com
192.168.1.200 www.sitetwo.no-ip.com


# The following lines are desirable for IPv6 capable hosts
# (added automatically by netbase upgrade)

::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts


Even still I cannot access sitetwo.com and just get the siteone.com website. :confused:


Did you restart Apache after modifying httpd.conf?

Yeah - everytime I make any changes to the file I am restarting Apache. I even tried a reboot to see if this was the problem but to no avail.

Thanks for your help.

Jamie

jme
03-15-2004, 10:42 AM
Found what the problem was - my own stupid fault really!

When I was testing the server by pointing my browser at the two sites I was accessing http://siteone.com instead of http://www.siteone.com.

Just had to add the ServerAlias tag to both of the hosts and we're off!

Nice feeling to have the working server just puring away in the corner of the room!! :D

Jamie