How To Set Up suPHP With PHP4 And PHP5

Version 1.0
Author: Falko Timme

This tutorial shows how to install and use suPHP with PHP4 and PHP5. suPHP is a tool for executing PHP scripts with the permissions of their owners instead of the Apache user. With the help of suPHP you can also have PHP4 and PHP5 installed at the same time which I will describe at the end of this article.

suPHP integrates into Apache2 as a module. At the time of this writing it does work with Apache2 prior to version 2.2. Version 2.2 is not supported yet.

This tutorial was written with the help of a Debian Sarge system, but as I compile suPHP from the sources here instead of installing some distribution specific suPHP packages, most of the steps should apply also to other distributions.

I want to say first that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. I do not issue any guarantee that this will work for you!

1 Install Apache

If you don't already have Apache2 installed, install it like this:

apt-get install apache2 apache2-doc

2 Disable the Apache PHP Module

If you already had Apache2 installed with PHP4 as a module, you must disable that module now because suPHP uses the CGI version of PHP to work (if you don't know if you have PHP4 installed as module, you can also run this command - it doesn't hurt):

a2dismod php4

Do the same for PHP5 if you have the PHP5 module installed (the official Debian Sarge repositories don't have PHP5 packages, however it's possible that you installed third-party PHP5 packages like those from

a2dismod php5

Then restart Apache:

/etc/init.d/apache2 restart

3 Install apxs

From suPHP's installation manual:

The easiest way to install mod_suphp is to compile it as a dynamically loadable module (DSO). If your Apache was compiled with DSO support and "apxs" is either in your path or you specified the path to it when running "configure", mod_suphp will automatically be compiled when doing "make" and installed to your Apache server (when doing "make install").

We want to install suPHP as a DSO, therefore we must install apxs (on Debian Sarge it's apxs2). It is provided by the apache2-prefork-dev package which we install now:

apt-get install apache2-prefork-dev
Share this page:

3 Comment(s)