Apache 1 and 2 on the same machine


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?

Who is Participating?
ramazanyichConnect With a Mentor Commented:
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.
NermalAuthor Commented:
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.

PsiCopConnect With a Mentor Commented:
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.
ahoffmannConnect With a Mentor Commented:
> 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
NermalAuthor Commented:

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

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.

All Courses

From novice to tech pro — start learning today.