NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP 4 and PHP 5 on One Apache 1.3.x Unix Installation

Andrew Yochum andrew at plexpod.com
Fri Jul 14 10:22:21 EDT 2006


Hi Peter,

On Fri, Jul 14, 2006 at 09:55:45AM -0400, Peter Sawczynec wrote:
>    Assuming that I have successfully installed safe and separate PHP 4 and
>    PHP 5 on a Unix box
>    running Apache 1.3.x. And that I have included and compiled in all the
>    extensions/libs that I need
>    under both (and that I am fully aware of the MySQL, XML and OOP support
>    issues).
>     
>    In order to switch from PHP 4 to PHP 5, can I simply go into the Apache
>    httpd.conf file
>    and change the directive:
>    "LoadModule php4_module        libexec/libphp4.so"
>    to
>    "LoadModule php5_module        libexec/libphp5.so"
>     
>    Then do a graceful reboot on Apache.
>     
>    So again I'm not concerned with individual scripting compatability
>    issuews, but do you see this strategy as
>    technically sound to allow me to flip back and forth between PHP 4 and PHP
>    5, if I so needed?

Yeah, that would work.  Personally, I do the following:
    1. Add an additional IP address to my dev box.  In a private network this
    might be:
        192.168.0.10
        192.168.0.11
    2. Setup two apache config files that:
        - each is bound to one or more IPs explicitly, not the wildcard */0.0.0.0
        - one uses PHP4, one uses PHP5
        - each may load the same or separate vhosts... depends on what you're
          trying to accomplish.  You can do name or IP based virtual hosting. Just
          make sure the two apache's IPs don't overlap.
       These might be:
           /etc/apache2/apache2-php4.conf
           /etc/apache2/apache2-php5.conf
    3. Setup a separate init script for each - one may be the same if you left
    one config file in the original place. These might be:
           /etc/init.d/apache2-php4
           /etc/init.d/apache2-php5
    4. Start your apaches:
        /etc/init.d/apache-php4 start
        /etc/init.d/apache-php5 start
    
Voila!  Then you don't need to edit or restart anything.  You have both
environments up and running seamlessly with neither running as a CGI, etc.

PS. The same strategy could be used to run a second apache on a separate port.

HTH,
Andrew
-- 
Andrew Yochum
Plexpod
andrew at plexpod.com
718-360-0879



More information about the talk mailing list