Problems with apache2 multiple virtual hosts

Problems with the Linux version of XAMPP, questions, comments, and anything related.

Problems with apache2 multiple virtual hosts

Postby novatec1@aol.com » 10. January 2013 23:51

I have an apache2 server that has been used to host one virtual site. I tried a add a second site (site2) but after creating the second virtual host it shows site1. Each site works independently as long as the other sites virtual host code is commented out. Any help is greatly appreciated. The code is as follows:

NameVirtualHost *:80

<VirtualHost site1.com:80>
ServerName site1.com
DocumentRoot /home/design/vhosts/site1.com/htdocs
ServerAlias http://www.site1.com
</VirtualHost>


<VirtualHost site2.com:80>
ServerName site2.com
DocumentRoot /home/design/vhosts/site2.com/htdocs
ServerAlias http://www.site2.com
</VirtualHost>
novatec1@aol.com
 
Posts: 1
Joined: 10. January 2013 23:27
Operating System: Linux

Re: Problems with apache2 multiple virtual hosts

Postby JonB » 14. January 2013 23:05

OK -

One thing before you go back to work on this - normally you would create an operational default fall-back vhost - in the case of lammp - often /opt/lampp/htdocs. I usually put the server IP+a description as the ServerName in the default vhost. Plus you would usually have some <Directory> entries for each of your vhosts, but you may be doing everything in .htaccess. But those are comments only

Now try this syntax:

Code: Select all
NameVirtualHost *

<VirtualHost *>
ServerName www.site1.com
DocumentRoot /home/design/vhosts/site1.com/htdocs
</VirtualHost>

<VirtualHost *>
ServerName www.site2.com
DocumentRoot /home/design/vhosts/site2.com/htdocs
</VirtualHost>



Good Luck
8)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7


Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 9 guests