I want to have both PHP4 and pHP5 on my system in more simple way. Already accomplished this before, but a little bit tedious. My hosting provider allow me to choose whether to use PHP4 or PHP5 for my site. I can even specify my own php.ini, so there must be some way to achieve this. Digging their knowledge base, I got the trade secret. They used Apache suEXEC to run PHP using FastCGI. Their setup also provide mod_php as a fallback if I don’t want to run PHP as a CGI. There are few benefits of this setup:-
- The PHP process is run as the user itself and not the default apache user as in mod_php.
- Using a wrapper, user can choose which binary (php4/php5) to run and also specify custom options to binary such as their own php.ini.
As for my developement purpose, this is great since I just need to specify different virtual host in my apache config pointing to the single application and have it tested in both platform (php4/php5). My setup can be seen here, in the wiki.
Reading Readme.FastCGI in php source, now I know that php also can be set to run as a seperate process from the web server, listening own it’s port serving request from the web server.
In this setup, PHP is started as a separate process entirely from the web server. It will listen on a socket for new FastCGI requests, and deliver PHP pages as appropriate. This is the recommended way of running PHP-FastCGI. To run this way, you must start the PHP binary running by giving it an IP and a port number to listen to on the command line, e.g.:
./php -b 127.0.0.1:8002
In term of performance and security, I can’t tell any word since no benchmark has been made and I’m not security expert.
