Maniak
Verified User
HOW TO : Apache(1&2) + Php 4 + Php 5 + Suphp 0.6.1
Important notice
This tutorial is no longer interesting for Directadmin users; please checkout this http://www.directadmin.com/forum/showthread.php?t=18266
Thanks.
Important notice
This tutorial is no longer interesting for Directadmin users; please checkout this http://www.directadmin.com/forum/showthread.php?t=18266
Thanks.
Introduction
This HOW-TO explain you how to setup suPHP 0.6.2 + PHP 4.4.x(CGI) + PHP 5.1.x(CGI).
Including a script that will create a php.ini for each user (existing and new). Just send me a private message.
It works also with Apache 2.2.x
Thanks to d0nuts, we have also solved some problems, it works perfectly.
I ran some successful tests on :
- Fedora Core 3 / 5
- Debian stable
- FreeBSD 6
If you want to try, just feel free. Actually you don't take big risks, because we will not overwrite any file, and we will just handle your php with suPHP, clearly it's pretty safe to try it.
Note
In order to configure and compile PHP5 you will need libxml2 and libxml2-devel. You can install it with all ways, yum, apt-get, ports of FreeBSD and even sources does not matter.
If you need professional support, contact me for further information.
Let's begin
# We download all what we need
[root@mandarine ~]# cd /usr/local/src/
[root@mandarine ~]# wget http://de.php.net/get/php-5.1.4.tar.gz/from/this/mirror
[root@mandarine ~]# wget http://de.php.net/get/php-4.4.2.tar.gz/from/this/mirror
[root@mandarine ~]# wget http://www.suphp.org/download/suphp-0.6.2.tar.gz
# UNTAR/UNZIP ALL
[root@mandarine ~]# tar -zxf php-5.1.4.tar.gz
[root@mandarine ~]# tar -zxf php-4.4.2.tar.gz
[root@mandarine ~]# tar -zxf suphp-0.6.2.tar.gz
# CONFIGURE & COMPILE PHP4
[root@mandarine ~]# cd php-4.4.2
[root@mandarine ~]# ./configure --prefix=/usr/local/php4 --enable-force-cgi-redirect --enable-fastcgi --with-config-file-path=/usr/local/etc/php4/cgi --with-curl --with-curl-dir=/usr/local/lib --with-gd --with-gd-dir=/usr/local/lib --with-gettext --with-jpeg-dir=/usr/local/lib --with-kerberos --with-mcrypt --with-mhash --with-mysql=/usr --with-pear --with-png-dir=/usr/local/lib --with-xml --with-zlib --with-zlib-dir=/usr/local/lib --with-zip --enable-bcmath --enable-calendar --enable-ftp --enable-magic-quotes --enable-sockets --enable-track-vars --enable-mbstring --enable-memory-limit
[root@mandarine ~]# make
[root@mandarine ~]# make install
# CONFIGURE & COMPILE PHP5
[root@mandarine ~]# cd ../php-5.1.4
[root@mandarine ~]# ./configure --prefix=/usr/local/php5 --enable-force-cgi-redirect --enable-fastcgi --with-config-file-path=/usr/local/etc/php5/cgi --with-curl --with-curl-dir=/usr/local/lib --with-gd --with-gd-dir=/usr/local/lib --with-gettext --with-jpeg-dir=/usr/local/lib --with-kerberos --with-mcrypt --with-mhash --with-mysql=/usr --with-pear --with-png-dir=/usr/local/lib --with-xml --with-zlib --with-zlib-dir=/usr/local/lib --with-zip --enable-bcmath --enable-calendar --enable-ftp --enable-magic-quotes --enable-sockets --enable-track-vars --enable-mbstring --enable-memory-limit
[root@mandarine ~]# make
[root@mandarine ~]# make install
# CONFIGURE & COMPILE suPHP
[root@mandarine ~]# cd ../suphp-0.6.2
[root@mandarine ~]# ./configure --prefix=/usr/local/suphp --sysconfdir=/usr/local/suphp/etc/ --with-apache-user=apache --with-setid-mode=owner --with-apxs=/usr/sbin/apxs --disable-checkpath
[root@mandarine ~]# make
[root@mandarine ~]# make install
# PREPARING CLEAN DIRECTORY
[root@mandarine ~]# mkdir -p /usr/local/etc/php4/cgi
[root@mandarine ~]# mkdir -p /usr/local/etc/php5/cgi
[root@mandarine ~]# mkdir -p /usr/local/suphp/etc
# COPYING PHP CONFIG FILES
[root@mandarine ~]# cp /usr/local/src/php-5.1.4/php.ini-dist /usr/local/etc/php5/cgi/php.ini
[root@mandarine ~]# cp /usr/local/src/php-4.4.2/php.ini-dist /usr/local/etc/php4/cgi/php.ini
[root@mandarine ~]# cp /usr/local/src/suphp-0.6.1/doc/suphp.conf-example /usr/local/suphp/etc/suphp.conf
# WE WILL COPY THE FILE WE WILL MODIFICATE...
[root@mandarine ~]# cp /usr/local/suphp/etc/suphp.conf suphp.conf.original
[root@mandarine ~]# cp /etc/httpd/conf/httpd.conf httpd.conf.original
# CREATE THE LOG FILE FOR suPHP
[root@mandarine ~]# touch /var/log/suphp.log
# CONFIGURE suPHP
[root@mandarine ~]# vi /usr/local/suphp/etc/suphp.conf
;User Apache is running as
webserver_user=apache
;Path all scripts have to be in
docroot=/
;Check wheter script is within DOCUMENT_ROOT
check_vhost_docroot=false
[handlers]
;Handler for php-scripts
x-httpd-php=php:/usr/local/php4/bin/php
x-httpd-php5=php:/usr/local/php5/bin/php
# CONFIGURING HTTPD.CONF
[root@mandarine ~]# vi /etc/httpd/conf/httpd.conf
# After this lines (or at the end of your LoadModule list) :
<IfDefine HAVE_PYTHON>
LoadModule python_module modules/mod_python.so
</IfDefine>
add :
LoadModule suphp_module /usr/lib/apache/mod_suphp.so
then, AND ONLY FOR APACHE 1!
after this lines (or at the end of your AddModule list) :
<IfDefine HAVE_PYTHON>
AddModule mod_python.c
</IfDefine>
add :
AddModule mod_suphp.c
Now again for both...
after AddHandler cgi-script .cgi .pl
add :
AddHandler x-httpd-php .php .inc .php4
AddHandler x-httpd-php5 .php5
and somewhere before your virtualhosts at the bottom
add :
<Location />
suPHP_Engine on
suPHP_ConfigPath /usr/local/etc/php5/cgi/
suPHP_AddHandler x-httpd-php
suPHP_AddHandler x-httpd-php5
</Location>
# TRY IF IT WORKS
[root@mandarine ~]# cd /var/www/html
create two files : test.php and test.php5 with inside :
<?
phpinfo();
?>
[root@mandarine ~]# chown -R apache.apache test.php test.php5
# RESTARTING ALL
[root@mandarine ~]# service httpd restart
go to http://YOURIP/test.php & http://YOURIP/test.php5
--------------------------------------
Now some important remarks
N° 1 : Don't forget to configure your both new php.ini files (/usr/local/etc/php4/cgi/php.ini && /usr/local/etc/php5/cgi/php.ini) - disable_functions etc...
N° 2 : If you get an Error 500 you should try to edit your file /usr/local/suphp/etc/suphp.conf and change :
; Minimum UID
min_uid=0
; Minimum GID
min_gid=0
it's not safe, but at least you will now if the problems comes from the UID/GID.
N° 3 : If you want to run exclusively PHP5 for .php and .php5 :
simply create a .htaccess in the public_html with inside :
AddHandler x-httpd-php5 .php
N° 4 : If you want to forbid one user to run PHP4/5, simply add inside his virtualhost this :
suPHP_Engine off
RemoveHandler .php
RemoveHandler .php5
N° 5 : If you want to offer to one user the possibility to have his own PHP.ini file just add inside his virtualhost this :
<Location />
suPHP_Engine on
suPHP_ConfigPath /home/youruser/domains/yourdomain/public_html/
suPHP_AddHandler x-httpd-php
suPHP_AddHandler x-httpd-php5
</Location>
--------------------------------------
Last update : 21-07-2006
Feedbacks welcome !
![]()
Last edited: