Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple ports on the same Apache Server. 1

Status
Not open for further replies.

MOrac

Programmer
Feb 2, 2005
189
NL
Two simple options; use virtual hosts with whatever name your DNS forwards (even the SAME name), and specify the differing listener ports; or use multiple instances of apache, one per port. It's up to you - the first is cheaper in resources and the second more stable as software failures can only take down individual servers.
 
Here's what I tried.

<VirtualHost *:81>
Listen 81
ServerAdmin webmaster@site1.com
ServerName 1.2.3.4
DocumentRoot "E:\Web\Apache2\htdocs\</VirtualHost>

<VirtualHost *:82>
Listen 82
ServerAdmin webmaster@site2.com
ServerName 1.2.3.4
DocumentRoot "E:\Web\Apache2\htdocs\</VirtualHost>

And here's the error I get when I try to start Apache

>>>> Syntax error on line 986 of E:/Web/Apache2/conf/httpd.conf

Line 986 is the "Listen 81" line in the example above.
 
There is a second error in event viewer...

>>> Listen cannot occur within <VirtualHost> section

 
You need to use:
Code:
Listen 81
Listen 82

<VirtualHost *:81>
    ServerAdmin webmaster@site1.com
    ServerName 1.2.3.4
    DocumentRoot "E:\Web\Apache2\htdocs\[URL unfurl="true"]www.site1.com"[/URL]
</VirtualHost>

<VirtualHost *:82>
    ServerAdmin webmaster@site2.com
    ServerName 1.2.3.4
    DocumentRoot "E:\Web\Apache2\htdocs\[URL unfurl="true"]www.site2.com"[/URL]
</VirtualHost>

The virtual host settings only help define how Apache breaks up the input it gets. The Listen directives, which are root directives, define what Apache listens to.
 
First of all, I am not able to use virtual hosts because #1 my box sits behind a NAT and #2 I am using a dynamic DNS with
So what I would like to do is have each of my web pages be on the same server but listening on a different port, I.E. site1 on port 81, site2 on port 82, etc... Then I will forward the actual DNS at my dynamic DNS host. will forward to 1.2.3.4:81 and will forward to 1.2.3.4:82. The problem is that I can't figure out how to make apache go to one directory when a request comes into port 81 and a different directory when a request comes into port 82.

Thanks

-Al
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top