Multiple Apache Installations HOWTO

Configuring Multiple Apache Installations

Because two Apache installations can not be installed into the same path, you have to use a different installation prefix for each different installation. In the examples that I show here I will compile PHP as a static module to Apache, as that is the best performing combination. It will take a little bit more time (15 seconds) to compile Apache too when upgrading PHP, but I can live with that.

Below I show a example configuration and compilation session of Apache and PHP. Everything in bold is something that you need to differ between different Installations on the same system.

cd apache-1.3.31

./configure --prefix=/usr/local/php43

cd ..

cd php-4.3.11

./configure --prefix=/usr/local/php43 --with-apache=/dat/src/apache-1.3.31 <other options>

make

make install

cd ..

cd apache-1.3.31

./configure --prefix=/usr/local/php43 --activate-module=src/modules/php4/libphp4.a --enable-module=rewrite --enable-module=proxy <other options>

make

make install

After setting it up for PHP 4.3, you can repeat the process above but change the 4.3.11 and /local/local/php43 to reflect PHP 4.4.

Allowing Multiple Apache Installations Running at the Same Time

Normally Apache runs on port 80 and it is impossible to have two Apache instances using this same port of course.
The easiest way is by allowing two IP addresses to be bound to one server, but using different ports in combination with a proxy server works as well ofcourse. In the setup on my development machines I simply use different ports for different Apache/PHP versions, such as :14311 for PHP 4.3.11 and :1510 for PHP 5.1.0-dev.

Two IP Address Setup

As you now have two different configuration files, one as /usr/local/php43/conf/httpd.conf and one as /usr/local/php44/conf/httpd.conf you can make your adjustments there. For example if you have two different IP addresses - one for each Apache installation you can use this:

Listen 10.0.2.35:80

This will cause Apache only to bind to one of the IP addresses on the machine (10.0.2.35 in my example, but ofcourse you need to use an IP addresseble address like 212.204.192.51 here), and only to port 80. In the other installations' configuration you need to select the other IP:

Listen 10.0.2.36:80

You also need to update your DNS according to where you placed the vhost for a specific site.

One IP - Multiple Ports and mod_proxy

If your server does not have the possibility to have more than one IP address, then you can deply a different setup. In this setup the configuration on the PHP 4.3 server contains all vhosts, but for the ones that are already moved to the PHP 4.4 server special apache configuration settings are added to redirect internally from the PHP 4.3 server to the PHP 4.4 one.
The configuration for the PHP 4.3 server should have the following statements:

Listen 10.0.2.35:80

NameVirtualHost 10.0.2.35.80

The listen statement for the PHP 4.4 server should be modified to that it listens at a different port than port 80:

Listen 127.0.0.1:8044

NameVirtualHost 127.0.0.1:8044

The vhost configuration of one of the sites that was moved to the PHP 4.4 server now looks in the PHP 4.3 server like:

<VirtualHost 10.0.2.35:80>

ServerName site1.example.com

DocumentRoot /usr/local/htdocs/ezpublish-site1

RewriteEngine On

RewriteRule !\.(gif|css|jpg|png|jar|ico|js)$ /index.php

</VirtualHost>

<VirtualHost 10.0.2.35:80>

ServerName site2.example.com

ProxyPass / http://site2internal:8044/

</VirtualHost>

And in the PHP 4.4 server configuration like:

<VirtualHost 127.0.0.1:8044>

ServerName site2internal

DocumentRoot /usr/local/htdocs/ezpublish-site2

RewriteEngine On

RewriteRule !\.(gif|css|jpg|png|jar|ico|js)$ /index.php

</VirtualHost>

You need to make sure that site2internal is configured in your /etc/hosts file:

127.0.0.1  localhost site2internal

This should be all that you have to do in to run PHP 4.3 and PHP 4.4 concurrently. (Or any two other PHP versions ofcourse).

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 03:05:14
Script start
Timing: Jan 18 2025 03:05:14
Module start 'layout'
Timing: Jan 18 2025 03:05:14
Module start 'content'
Timing: Jan 18 2025 03:05:14
Module end 'content'
Timing: Jan 18 2025 03:05:14
Script end

Main resources:

Total runtime0.0575 sec
Peak memory usage2,048.0000 KB
Database Queries23

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0058 587.9375152.6250
Module start 'layout' 0.00580.0025 740.562539.4453
Module start 'content' 0.00830.0476 780.0078445.8438
Module end 'content' 0.05590.0015 1,225.85168.3750
Script end 0.0574  1,234.2266 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00295.0706150.0002
Check MTime0.00122.1616150.0001
Mysql Total
Database connection0.00081.392710.0008
Mysqli_queries0.020435.5069230.0009
Looping result0.00010.2610210.0000
Template Total0.029050.420.0145
Template load0.00213.643120.0010
Template processing0.026946.751520.0134
Template load and register function0.00010.177610.0001
states
state_id_array0.00101.805210.0010
state_identifier_array0.00122.123420.0006
Override
Cache load0.00173.0119300.0001
Sytem overhead
Fetch class attribute name0.00061.101810.0006
class_abstraction
Instantiating content class attribute0.00000.006610.0000
General
dbfile0.00050.8710100.0001
String conversion0.00000.012040.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/article.tplextension/sevenx/design/simple/override/templates/full/article.tplEdit templateOverride template
1content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/header.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/header.tplEdit templateOverride template
12content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
8content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 29
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs