What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » [Fixed] Multiple VirtualHosts?

[Fixed] Multiple VirtualHosts?
Author: Message:
hmaster
Senior Member
****

Avatar

Posts: 716
Reputation: 24
33 / Male / Flag
Joined: Nov 2004
O.P. Huh?  [Fixed] Multiple VirtualHosts?
I have a Apache server running on my desktop and I was wondering how I can get more than one virtual host, eg http://localhost/ is currently pointed to my main folder but I'd like another one, http://localhost2/ or w/e, to point to another folder for a specific site.

I've been told it is possible but I can't find a tutorial that has actualy worked.

Running:
Apache 2
PHP 5


Any help appreciated, thanks.


Solution:
In the hosts file it should look like:
code:
127.0.0.1 name1
127.0.0.2 name2
127.0.0.3 name3
And in the httpd.conf file it should be like this:
code:
<VirtualHost 127.0.0.1>
    DocumentRoot C:/path
    ServerName name1
</VirtualHost>

<VirtualHost 127.0.0.2>
    DocumentRoot C:/path/to2
    ServerName name2
</VirtualHost>

<VirtualHost 127.0.0.3>
    DocumentRoot C:/path/to/it
    ServerName name3
</VirtualHost>

This post was edited on 11-11-2006 at 07:26 PM by hmaster.
[Image: sig.png]
10-26-2006 10:38 AM
Profile PM Web Find Quote Report
Sypher
Senior Member
****

Avatar

Posts: 623
Reputation: 15
37 / Male / Flag
Joined: Apr 2003
RE: Multiple Localhosts?
First of all, for these things don't use "localhosts" but virtualhosts.

In the apache config you can create virtual hosts.

Apache 2.2: http://httpd.apache.org/docs/2.2/vhosts/
Apache 2.0: http://httpd.apache.org/docs/2.0/vhosts/

In the apache config you add:

code:
NameVirtualHost *

If you want him to listen at all IP's you have.

Then for the vhosts, add this:
code:
<VirtualHost 123.123.123.123>
ServerAdmin webmaster@host.foo.com
DocumentRoot /www/docs/host.foo.com
ServerName host.foo.com
ErrorLog logs/host.foo.com-error_log
TransferLog logs/host.foo.com-access_log
</VirtualHost>
and for the second one
code:
<VirtualHost 123.123.123.123>
ServerAdmin webmaster@host.foo2.com
DocumentRoot /www/docs/host.foo2.com
ServerName host.foo2.com
ErrorLog logs/host.foo2.com-error_log
TransferLog logs/host.foo2.com-access_log
</VirtualHost>

You should adapt these things to your own settings, like the IP.

If you want to create "localhost2" you can edit your hostsfile.
In Windows XP this is located at
c:\WINDOWS\system32\drivers\etc\hosts

Normally it would look like this:
code:
127.0.0.1       localhost

Change it to

code:
127.0.0.1       localhost
127.0.0.1       localhost2

Should work. Good luck!

This post was edited on 10-26-2006 at 12:04 PM by Sypher.
Messenger Plus Beta Tester
Plus! Live Faq Maintainer
10-26-2006 12:03 PM
Profile PM Find Quote Report
hmaster
Senior Member
****

Avatar

Posts: 716
Reputation: 24
33 / Male / Flag
Joined: Nov 2004
O.P. RE: Multiple VirtualHosts?
quote:
Originally posted by Sypher
First of all, for these things don't use "localhosts" but virtualhosts.

Thanks.

quote:
Originally posted by Sypher
Long post...
It recognises that there is a second vhost but doesn't allow me to view files.

This post was edited on 10-26-2006 at 01:32 PM by hmaster.
[Image: sig.png]
10-26-2006 01:24 PM
Profile PM Web Find Quote Report
Sypher
Senior Member
****

Avatar

Posts: 623
Reputation: 15
37 / Male / Flag
Joined: Apr 2003
RE: Multiple VirtualHosts?
Try checking the logfiles then :)
Messenger Plus Beta Tester
Plus! Live Faq Maintainer
10-31-2006 01:56 PM
Profile PM Find Quote Report
Adeptus
Senior Member
****


Posts: 732
Reputation: 40
Joined: Oct 2005
RE: Multiple VirtualHosts?
You are probably missing a <Location> directive telling the server it is allowed to serve files under whatever the local path for the files is.

There is no substitute to thorough reading of the documentation.  :P
10-31-2006 02:55 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On