Apache 1 and 2 on the same machine

Posted on 2005-04-27
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

    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.
    LVL 1

    Author Comment

    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

    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

    > 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
    LVL 1

    Author Comment


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


    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Suggested Solutions

    As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
    Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    730 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now