PHP4 & PHP5 on MacOSX

This article explains how to set up PHP4 & PHP5 on MacOSX. It has been tested on MacOS 10.4.2 and with the Entropy packages: Entropy-PHP-4.3.11.dmg and Entropy-PHP-5.0.4.dmg.

PHP4 & PHP5 cannot run on the same Apache server. The idea is to have two different configurations and just switch between them. Entropy provides two packages one with PHP4 and one with PHP5, these packages are good for developement of PHP projects. They include GD which is not installed by default on MacOS X.

Installation

  1. Download PHP4 & PHP5 From Entropy web site

  2. Install PHP 4 Package

  3. Open a terminal window and enter these commands

    $ sudo mv /usr/lib/php /usr/lib/php4
    $ sudo ln -s /usr/lib/php4 /usr/lib/php

  4. Install PHP 5 Package

  5. Open a terminal window and enter these commands

  6. Now we need to edit the /etc/httpd/httpd.conf

    $ sudo emacs /etc/httpd/httpd.conf

    Jump to the end of the file, change the line :
    ‘Include /usr/local/php5/httpd.conf.php’ by ‘Include /usr/local/php/httpd.conf.php’

  7. Download the [php_switcher.sh bash script

    http://rabaix.net/pub/php_switcher.sh $ chmod 755 ~/Desktop/php_switcher.sh
    $ sudo cp ~/Desktop/php_switcher.sh /usr/bin/php_switcher.sh

  8. when you want to switch between php4 and php5

    $ sudo php_switcher.sh php5 # lunch apache with php5
    $ sudo php_switcher.sh php4 # lunch apache with php4

Note : You need to lunch the command with sudo, make sure you have enable the root user.
Applications > Utilities > NetInfo
Security > Enable Root User

Ressources

Improvement

It will be great to have this switcher in the menu bar with a nice php5 or php4 icon. However, I am not an expert of AppleScript or Cacao, so if you are and have some spare times. You know what to do.