Problem creating 2 vhosts [SOLVED]

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

Problem creating 2 vhosts [SOLVED]

Postby kambinator » 05. January 2012 09:54

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
Last edited by kambinator on 05. January 2012 15:02, edited 1 time in total.
kambinator
 
Posts: 2
Joined: 05. January 2012 09:20
Operating System: Windows 7 x86 (32 bit)

Re: Problem creating 2 vhosts

Postby Sharley » 05. January 2012 10:07

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. :)
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: Problem creating 2 vhosts

Postby kambinator » 05. January 2012 15:02

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>
kambinator
 
Posts: 2
Joined: 05. January 2012 09:20
Operating System: Windows 7 x86 (32 bit)

Re: [SOLVED] Problem creating 2 vhosts

Postby Sharley » 05. January 2012 23:21

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.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 45 guests