Apache 2.2 - Multiple Ports

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!
LVL 5
basiclifeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

giltjrCommented:
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
giltjrCommented:
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
basiclifeAuthor Commented:
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
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

basiclifeAuthor Commented:
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
giltjrCommented:
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
basiclifeAuthor Commented:
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
giltjrCommented:
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
basiclifeAuthor Commented:
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
giltjrCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
basiclifeAuthor Commented:
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
basiclifeAuthor Commented:
Oh and apologies, but more complete answer: no, no aliases and (currently) no webpages as such, jsut VERY small index.php 's ....
0
basiclifeAuthor Commented:
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
giltjrCommented:
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
basiclifeAuthor Commented:
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
giltjrCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.