Solved

Apache 2.2 - Multiple  Ports

Posted on 2007-03-18
15
266 Views
Last Modified: 2012-05-05
I asked this question before but got no decent answer. I know it's possible.

I have 2 codebases, I want them served using the same instance of apache 2.2, but on different ports (On windows XP).

Can someone please tell me what I need to do in the config file to set this up? Thanks!
0
Comment
Question by:basiclife
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 7
15 Comments
 
LVL 57

Expert Comment

by:giltjr
ID: 18743694
I am not sure what you mean by 2 bodebases, but I would assume that you can create two virtual hosts and specify the ports you want to use there:

<Virtualhost 1.2.3.4:81>
Servername codebase1
"other required virtual hosts statments>
</Virtualhost>


<Virtualhost 1.2.3.4:82>
Servername codebase2
"other required virtual hosts statments>
</Virtualhost>
 
0
 
LVL 57

Expert Comment

by:giltjr
ID: 18743700
Now just remember that when somebody want to get to codebase1 they will need to enter:

     http://codebase1:81

and when they want to get to codebase2 it would be:

     http://codebase2:82

0
 
LVL 5

Author Comment

by:basiclife
ID: 18743843
That sounds like exactly what I need. by codebases, I suppose I mean document roots....

Will give it a try and be back to you ASAP
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Author Comment

by:basiclife
ID: 18743853
Ok I have:

Listen 80
Listen 81

<VirtualHost <myip>:81>
      ServerName <myip>
      DocumentRoot "D:/Webserver/Test"
      Options Indexes FollowSymLinks
</VirtualHost>

and the main config points to a different directory...

In theory, 80 should be my main server, 81 should be my test environment, but both ports are pointing to the normal codebase, ignoring the virtual host... Any suggestions?
0
 
LVL 57

Expert Comment

by:giltjr
ID: 18744124
Do you have another virtual host definition?  If not, then your "main server" is your only server which is "D:/Webserver/Test"

If you have another virtual host definition, is it the 1st virtual host definition in your config file?

When doing virtual hosts you must define each virtual host specifically.  The "main" server is the first virtual host defined, also called the default host.

So you may need to add:

<VirtualHost <myip>:80>
      ServerName <myip2>
      DocumentRoot "D:/Webserver/Default"
      Options Indexes FollowSymLinks
</VirtualHost>

BEFORE the other virtual host definition.
0
 
LVL 5

Author Comment

by:basiclife
ID: 18744133
So even though it works with no vhost definitions, you need to have to add it again if you use vhosts?

I'll give it a ry. am off to bed now but will get back to you tomorrow. thanks!
0
 
LVL 57

Expert Comment

by:giltjr
ID: 18744217
Correct.  With no vhost defintions there is only "one" site.

Once you start using virtual hosts there are mutliple sites.  The default site, the first virutual host defined in your configuration file, and then all of the other sites.
0
 
LVL 5

Author Comment

by:basiclife
ID: 18770941
Ok, I have:


<VirtualHost <IP>:80>
      ServerName <IP>:80
      DocumentRoot "D:/Webserver/Live"
</VirtualHost>

<VirtualHost <IP>:81>
      ServerName <IP>:81
      DocumentRoot "D:/Webserver/Test"
</VirtualHost>

      Listen 80
      Listen 81


I have tried with and without the port number on the servername directive. unfortunately, I'm STILL getting "D:/Webserver/Live" on both 80 and 81

Any suggestions? (and yes, I've restarted, etc...)
0
 
LVL 57

Accepted Solution

by:
giltjr earned 500 total points
ID: 18771521
What you have looks good.  You can go to:

     http://httpd.apache.org/docs/2.0/vhosts/examples.html

and search on the string:

     "Running different sites on different ports."

and it will show you an example that is "just like" what you have.  The only differnes is that you are on Windows and their example is for *nix.  I am at work and do not have access to my server to test (but it is Linux, so there could be somethind weird with Windows).  So I will need to get back to you latter on tonight after I test you definitions on mine.

But a few questions until then:

Do you have any alias statments for either of these directories?

Do you refere to these aliases within your web pages?

Do you actually have a different index.html (or what ever you use in the DirectoryIndex)   file in each of the documentroots?

I spent 3 days trying to figure out why a virtual host setup was not working only to find out the person that actually loaded the web pages put the same exact pages in both document roots.
0
 
LVL 5

Author Comment

by:basiclife
ID: 18771711
I have 2 sub-folders - /Test and /Live, I have an index.php in each, one prints "Test", tthe other prints (surprise!) "Live" - just so I can confirm where the page is being served from (and I did double-check to make sure I hasn't mconfused them...)

So as far as I can tell, it should be different. I've looked at the link you sent, that's what I based my config on.

Any help you can provide would be greatly appreciated.

Thanks!
0
 
LVL 5

Author Comment

by:basiclife
ID: 18773499
Oh and apologies, but more complete answer: no, no aliases and (currently) no webpages as such, jsut VERY small index.php 's ....
0
 
LVL 5

Author Comment

by:basiclife
ID: 18787971
For some reason using _default_ instead of the IP address in the virtualhost directoves worked (suggested by someone on apachelounge.com

I'm going to award the points as you've been so helpful, but with a grade of C as the answer wasn't  correct. For the record, I suspect this is something buggy with the windows implementation as all changes were as-per the manual.

Thanks for your help!
0
 
LVL 57

Expert Comment

by:giltjr
ID: 18788048
Ummm, interesting.  I setup Apache 2.2 and 2.0 the the exact statements (of couse with my comptuers IP address) you had under Windows XP and it worked just fine without using _default_.

The only way I can think that what you had is that the IP address you coded on the virtual host statments is not a valid IP address for your computer.
0
 
LVL 5

Author Comment

by:basiclife
ID: 18788664
Possibly so... but I tried with both my internal and external IPs so I'm really not sure WTH is going on. Sorry for the C - I tend to go with A, but can't really justify it for no answer.
0
 
LVL 57

Expert Comment

by:giltjr
ID: 18789974
Oh, I really don't care about the grade, in fact would not have minded if you had asked for a refund.  I am more concerned as to why it was not working for you.  What Apache were you using?  All _default_ does is tell Apache to listen on all IP addresses assigned to the host.  Say you have 3 IP addresses on your computer:

    1.1.1.1
    1.1.2.1
    1.1.3.1

If you had:

     <VirtualHost 1.1.1.1:80>
     "virtualhost defs"
     </VirtualHost>
    <VirtualHost 1.1.1.1:81
     "virtualhost defs"
     </VirtualHost

Then any requests to 1.1.2.1 or 1.1.3.1 would fail.  Only requests to 1.1.1.1, for either port, would actually work.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question