Running multiple ports with Apache

S

(Shovel)

Guest
Ello there, Apache configuration question.

I run Apache on my PC (Windows XP) to preview websites I'm building, but I'm increasingly finding that I've got more than one site on the go, and I've discovered that I'd rather like to have a little personal organiser page and accounting stuff with mySQL run on there as well. Now, messing with subfolders isn't really very slick, nor is it ideal at all for working with test sites, since they will be sitting on the root once deployed.

Is it possible to set up Apache to run on (say) port 80, 81, 82 etc with a different document source for each?

Ta.
 
T

TheJkWhoSaysNi

Guest
What about running multiple copies of apache?
 
F

FatBusinessman

Guest
Looks like virtual hosts are the way to go. You probably want something like this in your httpd.conf file:
Code:
NameVirtualHost *

<VirtualHost *>
    ServerName localhost
    DocumentRoot /www/respectable
</VirtualHost>

<VirtualHost *>
    ServerName porn.localhost
    DocumentRoot /www/rampantsex
</VirtualHost>

Rather more self-explanatory than using different ports, and has the advantage that you don't have to worry whether another app is using the port in question.

(Note: I take no responsibility if this is all wrong :))
 
P

Panda On Smack

Guest
I have Win2k server running IIS and MS SQL 2000 to test all my sites, is it worth changing to Apache?
 
F

FatBusinessman

Guest
Yes. It's more secure, cross-platform and has wider support for extra modules.
 
S

(Shovel)

Guest
Originally posted by FatBusinessman
Yes. It's more secure, cross-platform and has wider support for extra modules.

If it's purely for testing, and if it matches what you need, then no, it's not worth changing.

If you want the experience of learning to set up a web server that's far more widespread in the real world then yeah, by all means go for it. Remember to use Apache 1.x though, since 2.x is still not recommended for use with PHP.

I fall you're doing is testing internally though, it probably isn't worth the effort, although yes, Apache is good for the reasons Fatty points.

IIS 6 is supposed to be a big inprovement, I don't know if anyone here has played with that though?

And thank you for the tips :)
 
S

(Shovel)

Guest
OK, issues with this whole virtual hosts buggery.

That link (thanks lovedaddy) mentions something about needing to set them in the DNS server? I looked up the equiv doc for apache 1.3 (the version I'm running) and it didn't mention it, but it does seem reasonable.

Basically, put the following in my httpd.conf:
Code:
#
# Use name-based virtual hosting.
#
NameVirtualHost *

#
# Main Docs
<VirtualHost *>
    DocumentRoot D:/bmpw/WebServ/docs/
    ServerName localhost
</VirtualHost>

# Ben-Ward Virtual Host
<VirtualHost *>
    DocumentRoot D:/bmpw/Documents/WebDev/ben-ward.2/
    ServerName benward.localhost
</VirtualHost>
But I enter "benward.localhost" and Firebird says it can't find it.

I also tried following the instructions on this site to do it using port declarations rather than subdomains, to which Firebird opens up the search page instead.

Can someone hold my hand a little more please?
 
T

Testin da Cable

Guest
Ben, you'll need to edit your hosts file (or lmhosts on windows) to allow windows to do a file based hostname lookup for benward.localhost. tbh, I'm not sure this setup is going to work because iirc you need separate IP numbers for each host.
 
F

FatBusinessman

Guest
Originally posted by Testin da Cable
iirc you need separate IP numbers for each host.
Not entirely true there...

From the Apache documentation
IP-based virtual hosts use the IP address of the connection to determine the correct virtual host to serve. Therefore you need to have a separate IP address for each host. With name-based virtual hosting, the server relies on the client to report the hostname as part of the HTTP headers. Using this technique, many different hosts can share the same IP address.
 
S

(Shovel)

Guest
Thankyou TeeDee and Fatty, I have it working lubbly now.

Basically, adding the following to the hosts file did the trick:
Code:
127.0.0.1       localhost benward.localhost ss2.localhost

I did try using a wildcard to see if that would then accept all future sub domains, but though it remembered benward.localhost, it didn't recognise the newer ss2 that I'd just added, so I can only assume that there is no "grab all" means of setting it up.

Thanks again.
 

Users who are viewing this thread

Top Bottom