This post follow my previous one PHP5 CGI & CLI with an existing PHP4 Modules installation here http://www.interworx.com/forums/showthread.php?t=1630
Here we will show you how to install php5, suphp and configure your box to have php4 and php5 running on the same box.
This will give you the ability to easily have on an interworx box php running as:
- php4 as module or cgi
- php5 as CGI
- More security (mod suPHP in paranoid mode + suexec)
You already have php4 installed as module
You want to install php5 as CGI and allow your users to run php5 scripts as CGI and php4 scripts as CGI too.
1/ First install the php5-cli-cgi RPM.
This rpm install only the cli and cgi version of php5.
All informations are there : http://www.interworx.com/forums/showthread.php?t=1630
2/Now install suPHP
-
Get the SRPM here http://clust01-carat01.carat-hosting.com/srpm/suphp-0.6.1-100.rhe4x.carathosting.src.rpm
-
Rebuild it with
rpmbuild --rebuild --with <yourarch> suphp-0.6.1-100.rhe4x.carathosting.src.rpm -
Install it
rpm -ivh suphp-0.6.1-100.rhe4x.carathosting.rpm
The config file of mod_suphp.conf in /etc/httpd/conf.d/mod_suphp
mod_suphp
LoadModule suphp_module modules/mod_suphp.so
<IfModule mod_suphp.c>
suPHP_Engine off
</IfModule>
Vhost config file of the user who’d like to have php5 and php4 in /etc/httpd/conf.d/domain.conf
…/…
ErrorLog /home/account/var/domain/logs/error.log
CustomLog /home/account/var/domain/logs/transfer.log combined
Insert suPHP Stuff here
AddHandler x-httpd-php .php
AddHandler x-httpd-php5 .php5
suPHP_Engine on
suPHP_UserGroup user group
suPHP_AddHandler x-httpd-php5 .php5
suPHP_AddHandler x-httpd-php .php
<Files *.php>
suPHP_ConfigPath /etc
</Files>
<Files *.php5>
suPHP_ConfigPath /etc/php5
</Files>
cgi: 1 don’t edit between this and the “end cgi” comment below
…/…
and finaly update the suphp.conf in /etc
…/…
; Security options
allow_file_group_writeable=true
allow_file_others_writeable=false
allow_directory_group_writeable=true
allow_directory_others_writeable=false
…/…
;Umask to set, specify in octal notation
umask=0077
…/…
[handlers]
;Handler for php-scripts
x-httpd-php=php:/usr/bin/php
x-httpd-php5=php:/usr/bin/php5
…/…
By default all file in the docroot ending by .php5 will be treat by suPHP handlers and the php5 binary, and all file ending by .php will be treat by suPHP handlers the php4 binary
If your users want to have all their files ending by .php treat by suPHP and php5 bianry just tell them to add in an .htaccess file this (or just update their vhost conf file by removing php4 stuff and changing php5 by these lines)
AddHandler x-httpd-php5 .php
AddType application/x-httpd-php5 .php
Finally we have php4 and php5 for this vhost. For example, here is the two phpinfo on the same domain
php4 : http://clust01-carat01.carat-hosting.com/phpinfo.php
php5 : http://clust01-carat01.carat-hosting.com/phpinfo.php5
Hope this will help