Author |
|
gordonsutton
Joined: 31 May 2006 Posts: 5
|
Posted: Wed 31 May '06 15:58 Post subject: Newbe - Multiple web sites on my pc |
|
|
Please excuse the ignorance in this question. I have searched the forum for information on virtual hosts and have found a lot of information. I am not sure how to approach this problem.
I have multiple web sites on my host server in subdirectories under the root directory. I want to replicate that environment on my personal pc. I can set up Apache for one site by putting the subdirectory in hconf file but I have to change it every time I want to work on another web site. I understand virtual host is the solutions for this but I cannot figure out how to setup apache and then access each site individually.
Could you provide me with some help or a link or the name of a book that would tell me in detail how to do this?
thanks,
Gordon Sutton |
|
Back to top |
|
Steffen Moderator
Joined: 15 Oct 2005 Posts: 3092 Location: Hilversum, NL, EU
|
Posted: Wed 31 May '06 16:35 Post subject: |
|
|
When you have a Domain name for each site then you can read the info is at http://httpd.apache.org/docs/2.2/vhosts/ . You have to use Name-based Virtual Hosts
When you do not have a domain name for each site the you can access a site by including the subdirectory name, eg. http://mydomain.com/sub-dir/...
Steffen |
|
Back to top |
|
ArtM
Joined: 23 Feb 2006 Posts: 59 Location: Bedford NS Canada
|
Posted: Thu 01 Jun '06 9:58 Post subject: |
|
|
Don't forget you may need a 'localized' and a 'standard Net' version of your C:\Windows\SYSTEM32\DRIVERS\ETC\HOSTS file to reflect from where your domains are currently being served and not all programs immediately pick up changes to this file - e.g., Firefox. |
|
Back to top |
|
mightyspawn
Joined: 26 May 2006 Posts: 18
|
Posted: Thu 01 Jun '06 14:54 Post subject: |
|
|
or buy a good router, like linksys. |
|
Back to top |
|
gordonsutton
Joined: 31 May 2006 Posts: 5
|
Posted: Fri 02 Jun '06 20:01 Post subject: Now I am really confused |
|
|
Maybe I should restate my question. I have my 3 production web sites at a host site and they are running fine. I want to expand them to use php and mysql to do other things. This means I need to develop and test my code on my personal pc at home.
What I wish to do is set up my personal pc to be able develop and test code that will be installed on the 3 production web sites. Since each site is different, I want to test each individually as I make the changes. As I understand this I need apache, php and mysql installed. I am an XP SP2 machine and are using Dreamweaver 8 and WebBuilder 2006 to develop and test the code.
I have installed apache and can get it to work with one root directory at a time. I want to be able to test more than one site without having to change the root directory in the conf file or to copy each site to the single root directory when I want to test.
I have put the virtual hosts in apache as follows:
<VirtualHost *:80>
ServerName unicowblog.com
DocumentRoot "M:/Sites_Test/gordonsutton/public_html/unicowblog"
</VirtualHost>
<VirtualHost *:80>
ServerName unicowfarm.com
DocumentRoot "M:/Sites_Test/gordonsutton/public_html/unicowfarm"
</VirtualHost>
<VirtualHost *:80>
ServerName pvfdaux.com
DocumentRoot "M:/Sites_Test/gordonsutton/public_html/pvfdaux"
</VirtualHost>
and checked the syntax with ApacheConf.
When I try to access a local website using http://localhost/unicowfarm.com in the firefox or explorer browsers I get a message that says localhost is forbidden or somehow it defaults to the production internet site.
I guess I don't understand how to access the local websites or have missed something on the way. I have gone through all of the documentation that I can find but cannot locate anything that addresses the subject in a manner I can understand it.
If you can point me to an article or book that addresses this situation I will be glad to read it and continue experiementing.
I appreciate your patience and help.
Gordon Sutton
|
|
Back to top |
|
emjay
Joined: 24 Jan 2006 Posts: 6 Location: Berlin, Germany
|
Posted: Sat 03 Jun '06 15:22 Post subject: How to get virtaulhosts working on Apache1/2 and windows xp |
|
|
Gordon,
the best way to do this is by editing your c:\windows\system32\drivers\etc\hosts to something like that
127.0.0.1 localhost
127.0.0.1 unicowblog.com
127.0.0.1 unicowfarm.com
an so on for each virtual host. I did this once with a php-commandline script, which automatically generated the entries in the hosts file for me.
I guess its the best, you backup your hosts file because if you want to visit the real domain on internet, you computer probably wouldnt find it beacause it first looks in the hosts file and then asks the stadard dns-server (on linux you can change this, on windows i never tried to...)
This setup works great for now 2 years on my pc.
Notice, that other computers on LAN wouldnt be able to connect to your testserver with this setup.
If you want this, you need to set up the hosts file on every computer who needs to connect like
192.168.0.1 unicowblog.com
or something like this, using the LAN-adress of the testserver, or you use in the hosts file of the testserver its LAN adress like
192.168.0.1 unicowblog.com
und take it as DNS-server for the other PC on LAN
The tricky thing is, that Windows needs to know, what ip the virtualhosts have. If you do like I have written, you would probably get it working.
One other thing:
You need tho tell apache for each VirtualHost, that everybody is allowed to access its root dir:
<VirtualHost *:80>
Servername unicowblog.com
DocumentRoot C:/your/document/root
<Directory "C:/your/document/root">
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Thts all
Good luck
emjay a.k.a. schneggerich.net |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Sat 03 Jun '06 17:31 Post subject: Re: How to get virtaulhosts working on Apache1/2 and windows |
|
|
emjay wrote: | Gordon,
the best way to do this is by editing your c:\windows\system32\drivers\etc\hosts to something like that
127.0.0.1 localhost
127.0.0.1 unicowblog.com
127.0.0.1 unicowfarm.com
|
that will only work local. From outside that will take no effect. But for using it only localy it works . Some browsers don't use this file (read full comment from ArtM)
As Steffen told you should use name based vhosts |
|
Back to top |
|
gordonsutton
Joined: 31 May 2006 Posts: 5
|
Posted: Sun 04 Jun '06 19:54 Post subject: Thanks For The Help |
|
|
Thanks for all of your help. I have made the changes that were suggested except for editing the C:\WINDOWS\SYSTEM32\DRIVERS\ETC\hosts file. The hosts file is protected and once I figure out how to edit it, I will make the host changes and give it a shot.
You guys have been really kind and appreciate very much
Gordon Sutton |
|
Back to top |
|
gordonsutton
Joined: 31 May 2006 Posts: 5
|
Posted: Fri 16 Jun '06 14:53 Post subject: Made Changes To Host File And Have Selection Problem |
|
|
I made the changes to the host file that were recommended.
What occurs now is that when I enter localhost into the brower url bar, I get the first vhost, i.e., //http://localhost will bring up the pvfdaux site if it is first in the vhost list. However, when I enter //http://localhost/pvfdaux I get the error message that the object is not found.
I can rearrange the vhosts in any way and get the same result.
I thought it was because I did not have the localhost 127.0.0.1 first in my hosts file but it seems to key on the order of the vhosts in conf file.
Any suggestions?
Thanks,
Gordon Sutton |
|
Back to top |
|
OldManRiver
Joined: 21 Jun 2006 Posts: 21
|
Posted: Thu 22 Jun '06 20:09 Post subject: 403 Error |
|
|
Hi,
I post thread:
http://www.apachelounge.com/viewtopic.php?t=462&sid=9797bed865fb1b2c444315da399ed146
and it was suggested I come to this thread to solve my problem.
I found and edited the C:\winnt\system32\drivers\etc\hosts file, the conf file, which tested good, rebooted and for:localhost
project1.com
project2.com
etc. I get the 403 error for all of them. Entries in the httpd.conf are: Code: | <VirtualHost *:80>
ServerName project1.com
DocumentRoot "E:/MyPath/Project1"
<Directory "E:/MyPath/Project1">
Order allow,deny
allow from all
</Directory>
ServerAdmin "admin@project1.com"
ErrorLog "logs/project1-error_log"
CustomLog logs/project1-access_log common
</VirtualHost> |
which is error free and I think is good for what I know so far.
So what is causing the 403 error?
OMR |
|
Back to top |
|
mortman20
Joined: 27 Jun 2006 Posts: 2
|
Posted: Tue 27 Jun '06 4:22 Post subject: short time line |
|
|
I am having the same trouble – except I was running ver 2.0.35 for a year no problem. Upgraded my MOBO and CPU reinstalled win XP/w SP2 copied my httpd file to the appropriate directory and only get the first virtual host (under Localhost) but cant get there by using the URL. I am using directupdate to update zoneedit, made no changes to my router during reloading the os and don’t use windows fire wall.
The only changes I made where hard ware. Any clues, I need to get this back up and running but am at a loss for this install
Thanks |
|
Back to top |
|