By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,119 Members | 2,064 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,119 IT Pros & Developers. It's quick & easy.

Settings up additional 'http://localhosts' (ie. localhost2, localhost3) in apache

P: n/a
Hi,

My knowledge of apache is nothing impressive,. I purely use it to run
local websites. I was wondering however, if it is possible to create
more local domains like localhost. I like my local websites to be able
to run in a simulated environment as my remote host. This would maybe
run like http://localhost, http://localhost2, http://localhost3 ...

Can it be done? Btw, Im running apache on Windows.

Burnsy

Nov 23 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
bizt wrote:
Hi,

My knowledge of apache is nothing impressive,. I purely use it to run
local websites. I was wondering however, if it is possible to create
more local domains like localhost. I like my local websites to be able
to run in a simulated environment as my remote host. This would maybe
run like http://localhost, http://localhost2, http://localhost3 ...

Can it be done? Btw, Im running apache on Windows.

Burnsy


How about asking in an Apache newsgroup? Or, the Apache users maillist
is even better.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Nov 23 '05 #2

P: n/a
Edit your HOSTS file. You will find it in
C:\Windows\System32\Drivers\Etc\.

Nov 23 '05 #3

P: n/a
>My knowledge of apache is nothing impressive,. I purely use it to run
local websites. I was wondering however, if it is possible to create
more local domains like localhost. I like my local websites to be able
to run in a simulated environment as my remote host. This would maybe
run like http://localhost, http://localhost2, http://localhost3 ...

Can it be done? Btw, Im running apache on Windows.


If you have access to DNS (e.g. you run a nameserver on your machine
or your LAN), you can point additional names (preferably ones not
in use by someone else, say, using the top-level domain ".local",
which will likely never be used on the global Internet), at 127.0.0.1
or the IP address of your server machine, then configure them as
virtual hosts in Apache. This will be seen only by hosts that use
your nameserver.

If you don't have access to DNS, you can do the same thing with the
HOSTS file on all the machines you want to have see the sites, then
configure virtual hosts on Apache.

Gordon L. Burditt
Nov 23 '05 #4

P: n/a

Chung Leong wrote:
Edit your HOSTS file. You will find it in
C:\Windows\System32\Drivers\Etc\.


your HOSTS probly says
127.0.0.1 localhost

below it, add
127.0.0.2 site2

goto your httpd.conf (in apache's dir, or somewhere nearby)
look for this (around line 150) : Listen 127.0.0.1:80 or something like
it. under it, add
Listen 127.0.0.2:80

near the bottom of httpd.conf, look for the virtualHost stuff. add this
under whatever is there:
<VirtualHost 127.0.0.2:80>
ServerName site2
DocumentRoot "C:/My Documents/_websites/folderforSite2/www/"
</VirtualHost>

Thats what I do, I have a test host for 23 sites that way, just adding
1 to the IP each time. If there are less steps i could take, I'd like
to know!

--
j

Nov 23 '05 #5

P: n/a
"bizt" <bi******@yahoo.co.uk> wrote in
news:11*********************@g43g2000cwa.googlegro ups.com:
Hi,

My knowledge of apache is nothing impressive,. I purely use it to
run local websites. I was wondering however, if it is possible to
create more local domains like localhost. I like my local websites
to be able to run in a simulated environment as my remote host. This
would maybe run like http://localhost, http://localhost2,
http://localhost3 ...

Can it be done? Btw, Im running apache on Windows.


Just add the domain names you wish to use in your hosts file
(\windows\system32\drivers\etc IIRC), then comes the tricky part if
you want to use more than one simultaneously. Study up on virtual
hosting for apache. It will allow you to run more than one
site(domain name) from the same server.

I serve 5 sites (stanmccann.us in my sig is just one of them) from my
little Linux box at home, then I also have test.org available to all
machines on my LAN. An added benefit of this method is I *can* access
test.org from anywhere by setting it in the local hosts file.

--
Stan McCann "Uncle Pirate" http://stanmccann.us/pirate.html
Webmaster/Computer Center Manager, NMSU at Alamogordo
http://alamo.nmsu.edu/ There are 10 kinds of people.
Those that understand binary and those that don't.
Nov 23 '05 #6

P: n/a
>> Edit your HOSTS file. You will find it in
C:\Windows\System32\Drivers\Etc\.


your HOSTS probly says
127.0.0.1 localhost

below it, add
127.0.0.2 site2

goto your httpd.conf (in apache's dir, or somewhere nearby)
look for this (around line 150) : Listen 127.0.0.1:80 or something like
it. under it, add
Listen 127.0.0.2:80

near the bottom of httpd.conf, look for the virtualHost stuff. add this
under whatever is there:
<VirtualHost 127.0.0.2:80>
ServerName site2
DocumentRoot "C:/My Documents/_websites/folderforSite2/www/"
</VirtualHost>

Thats what I do, I have a test host for 23 sites that way, just adding
1 to the IP each time. If there are less steps i could take, I'd like
to know!


There are two methods of having Apache handle multiple sites on the
same server. The one you indicate requires multiple IPs on the
server. While you aren't likely to run out of IPs for localhost
any time soon (you've got about 16 million of them), running out
of public IPs can be a real problem, especially if you're on a DSL
line which only gives you one. Using up a whole class C (253 usable
addresses) or more for one web hosting company web server is a bit
of a waste.

The other method of doing virtualhosting is to put them all on the
same IP address (and the same port). The browser, except for those
that are SERIOUSLY out of date (and were seriously out of date in
2000), such as Netscape 2.*) will send a Host: header with the
request, indicating which host name it was for. Apache will sort
out which virtualhost is being addressed from the host name. If
you send it a host name it doesn't recognize, you'll get a default
site. Read the Apache manual for more details. You *need* to have
working DNS (or edit the HOSTS file) since putting in an IP address
to the browser will not let the browser know which site you want.

Gordon L. Burditt
Nov 23 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.