[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Apache 1 and 2 on the same machine

Posted on 2005-04-27
Medium Priority
Last Modified: 2010-03-04

Due to circumstances outside of my control I need to achieve the following.

I need to run both Apache ver 1 and version 2 on the same machine to serve two different sites, these would be http://website1.domain.mine and http://website2.domain.mine
Obviously both versions of apache cannot listen on the same port (80) as far as I am aware, so one will need to be run on port 8080. This would mean that website2 would need to be addressed by using http://website2.domain.mine:8080

I need to set this up so that website2 can be called without the need for the port number.

I realise that there are probably much better ways of doing this, but I need to get it up and running in this format for the time being.

What would be the easiest way of achieving this?

Question by:Nermal
LVL 19

Accepted Solution

ramazanyich earned 1000 total points
ID: 13876877
Actually you can run two versions of apache on the same port if they will use different IP addresses.
You can provide IP address for Listen directive.
for example your website1 has address and website2 has address
So in Apache 1 conf file you provide:


and in apache2 conf file:

Problem will be if your both DNS names refer to the same IP address.

Author Comment

ID: 13878257
Thankyou, I did not realise you could do that.
The DNS will not be a problem, I can setup a second IP address for the second site.

I will let you know how I get on tomorrow.

LVL 34

Assisted Solution

PsiCop earned 500 total points
ID: 13878571
As noted, you can run both on the same IP address if you do not bind them to the same port.

Apache1 conf:


Apache2 conf:


You don't want one website to have to be called by its port? Use mod_rewrite on the Apache instance on Port 80.

Not that using the second IP address is "bad", just pointing out an alternative.
LVL 51

Assisted Solution

ahoffmann earned 500 total points
ID: 13886060
> I need to set this up so that website2 can be called without the need for the port number
configure apache for website1 (let's say apache1) with a virtual host for website2, in the virtual host section you then use mod_rewrite to redirect all requests to your apache2 (which realy serves website2) which listens on port 81 or 8080 or whatever.
Example of httpd.conf for apache1:

NameVirtualHost your-IP-here
<VirtualHost *>
   ServerName website2.domain.mine
  RewriteEngine On
  RewriteCond %REQUEST_URI} ^.*
  RewriteRule ^(.*)$ http://IP-of-website2.domain.mine:81/$1 [P,L]

apache2 is configured to listen on port 81, that's it

Author Comment

ID: 13897437

Thanks for these, I have tried both (just for fun) and they worked exactly as needed.


Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month20 days, 8 hours left to enroll

868 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