Effortlessy switching between php4 and php5 for web development

I want to test my software on both php4 and php5 quickly and easily. Here’s the solution I came up with.

First, take out everything regarding php out of your main apache config. LoadModule phpX_module ..., AddModule mod_phpX.c, and anything else.

Next, make three files in the same directory as your apache config (/etc/httpd/ on OS X):

php4.conf

LoadModule php4_module        /usr/local/php/libphp4.so
AddModule mod_php4.c
Include /etc/httpd/php_stuff.conf

php5.conf

LoadModule php5_module        libexec/httpd/libphp5.so
AddModule mod_php5.c
Include /etc/httpd/php_stuff.conf

php_stuff.conf

AddType application/x-httpd-php .php

<IfModule mod_dir.c>
  DirectoryIndex index.html index.php
</IfModule>

Now add this line to the bottom of your httpd.conf:

Include /etc/httpd/php.conf

Now make the following two shell scripts and put them somewhere like ~/bin:

p4

cp /etc/httpd/php4.conf /etc/httpd/php.conf
apachectl graceful

p5

cp /etc/httpd/php5.conf /etc/httpd/php.conf
apachectl graceful

Ta da! Now to switch between php4 and php5, you can just do sudo p4 and sudo p5.

It would be nice to even tie this into an applescript with some sort of dock or even menu bar presence… if anyone has any tips on how this might be done let me know.

0 Responses to “Effortlessy switching between php4 and php5 for web development”


  1. No Comments

Leave a Reply




Close
Powered by ShareThis
All of mp3