Page 1 of 1

Problem creating 2 vhosts [SOLVED]

PostPosted: 05. January 2012 09:54
by kambinator
Hello!
I have successfully configured one host added
Code: Select all
<VirtualHost *:80>
    ServerAdmin admin@kambinator.myftp.biz
    DocumentRoot "C:/xampp/htdocs/prestashop/"
   ServerName magazin.myftp.biz
  ServerAlias www.magazin.myftp.biz
    ErrorLog "magazin.log"
    CustomLog "magazin.log" combined
</VirtualHost>

into C:\xampp\apache\conf\extra\httpd-vhosts.conf all workes fine!

I added another folder to C:\xampp\htdocs for example a folder with a simple index.html file (therefore i'm trying to install joomla)
added another host
Code: Select all
<VirtualHost *:80>
    ServerAdmin admin@kambinator.myftp.biz
    DocumentRoot "C:/xampp/htdocs/mysite/"
   ServerName kambinator.myftp.biz
  ServerAlias www.kambinator.myftp.biz
    ErrorLog "kambinator.log"
    CustomLog "kambinator.log" combined
</VirtualHost>

into C:\xampp\apache\conf\extra\httpd-vhosts.conf (after the first one)
Saved the file and restarted apache
if i write in my browser kambinator.myftp.biz it goes to the first host (magazin.myftp.biz) and if i write magazin.myftp.biz it also goes to magazin.myftp.biz


If i change the hosts places in C:\xampp\apache\conf\extra\httpd-vhosts.conf like this:
Code: Select all
<VirtualHost *:80>
    ServerAdmin admin@kambinator.myftp.biz
    DocumentRoot "C:/xampp/htdocs/mysite/"
   ServerName kambinator.myftp.biz
  ServerAlias www.kambinator.myftp.biz
    ErrorLog "magazin.log"
    CustomLog "magazin.log" combined
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin admin@kambinator.myftp.biz
    DocumentRoot "C:/xampp/htdocs/prestashop/"
  ServerAlias www.magazin.myftp.biz
    ErrorLog "magazin.log"
    CustomLog "magazin.log" combined
</VirtualHost>


just change their places (put the second into first's place) and try to access in browser kambinator.myftp.biz or magazin.myftp.biz both lead me to the first vhost content :shock:

So only the first one works (both lead to the first host)

HOW CAN I MAKE THEM WORK BOTH AT THE SAME TIME? Separately they work fine both

PS: I use dns from no-ip.org and run NO-IP DUC all seems to work fineImage

Re: Problem creating 2 vhosts

PostPosted: 05. January 2012 10:07
by Sharley
Try this by copy and paste and see if it works
Code: Select all
NameVirtualHost *:80

<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/xampp/htdocs"
</VirtualHost>

<VirtualHost *:80>
ServerName kambinator.myftp.biz
ServerAlias www.kambinator.myftp.biz
DocumentRoot "C:/xampp/htdocs/mysite"
ServerAdmin admin@kambinator.myftp.biz
ErrorLog "magazin.log"
CustomLog "magazin.log" combined
</VirtualHost>

<VirtualHost *:80>
ServerName magazin.myftp.biz
ServerAlias www.magazin.myftp.biz
DocumentRoot "C:/xampp/htdocs/prestashop"
ServerAdmin admin@kambinator.myftp.biz
ErrorLog "magazin.log"
CustomLog "magazin.log" combined
</VirtualHost>
No trailing slash in the DocumentRoot.
Save the file and restart Apache.

If Apache can't start read the C:\xampp\apache\logs\error.log file.

The first vhost will always be served by default unless the httpd-vhosts.conf file is in the correct format and all directives are included.

Make sure in your Windows hosts file (C:\Windows\system32\drivers\etc\HOSTS) you have the first line after the comments
Code: Select all
127.0.0.1 localhost


IMPORTANT SECURITY TIP:
Make sure in XAMPP 1.7.4 you have secured the C:\xampp\webdav folder if you intend to allow access from the Internet - the link in my signature will help.

Good luck. :)

Re: Problem creating 2 vhosts

PostPosted: 05. January 2012 15:02
by kambinator
Thank you so much! Problem is solved! :D
I didn't have this section at the beginning
Code: Select all
NameVirtualHost *:80
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/xampp/htdocs"
</VirtualHost>

Re: [SOLVED] Problem creating 2 vhosts

PostPosted: 05. January 2012 23:21
by Sharley
Thanks for the feedback. 8)

I will close this topic now.

Please feel free to start a new topic if you have any more issues with XAMPP for Windows.

Bets wishes.