Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Apache 2.2 - Multiple  Ports

Posted on 2007-03-18
15
Medium Priority
?
284 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
Looking for a new Web Host?

Lunarpages' assortment of hosting products and solutions ensure a perfect fit for anyone looking to get their vision or products to market. Our award winning customer support and 30-day money back guarantee show the pride we take in being the industry's premier MSP.

 
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 1000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

604 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