As requested by a client, I need installing both php5 and php4 in my debian based server. To switch between php versions, suphp can do the job. However the pre-built package by debian team cannot be use directly, I edited, recompiled and packaged suphp before use.

I noted the procedure of rebuilding the suphp package here.

developer@dev:/tmp/rebuild$ apt-get source libapache2-mod-suphp
Reading Package Lists... Done
Building Dependency Tree... Done
Need to get 112kB of source archives.
Get:1 stable/main suphp 0.5.2-3 (dsc) [711B]
Get:2 stable/main suphp 0.5.2-3 (tar) [105kB]
Get:3 stable/main suphp 0.5.2-3 (diff) [6720B]
Fetched 112kB in 3s (30.5kB/s)
dpkg-source: extracting suphp in suphp-0.5.2
developer@dev:/tmp/rebuild$ ls
suphp-0.5.2 suphp_0.5.2-3.diff.gz suphp_0.5.2-3.dsc suphp_0.5.2.orig.tar.gz

Next, root privilege is required to install the dependent packages, we ‘su’.

dev:/tmp/rebuild# apt-get build-dep libapache2-mod-suphp
Reading Package Lists... Done
Building Dependency Tree... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Here shows no changes, since I have installed the packages already; but you may have to install some of the packages like gcc, debian-build..etc.

developer@dev:/tmp/rebuild$ cd suphp-0.5.2/
developer@dev:/tmp/rebuild/suphp-0.5.2$ ls
AUTHORS ChangeLog README config doc
COPYING INSTALL NEWS aclocal.m4 configure debian src
developer@dev:/tmp/rebuild/suphp-0.5.2$ ls src/ apache2 check.h compat.h error.h filesystem.h log.h suphp.h
apache check.c compat.c config.h error.c filesystem.c log.c suphp.c types.h
developer@dev:/tmp/rebuild/suphp-0.5.2$ vi src/check.c

Now, let’s edit the src/check.c:
int check_permissions(char *script_path)
struct stat file_info;
if (stat(script_path, &file_info))
suphp_log_error("Could not stat() script %s", script_path);
error_sysmsg_exit(ERRCODE_UNKNOWN, "stat() failed", __FILE__, __LINE__);
if (!(file_info.st_mode & S_IRUSR))
suphp_log_error("Owner doesn't have read permission on %s", script_path);
return 0;
/* commented out by miguel for ispconfig to allow group management on files */
/* if (file_info.st_mode & (S_IWGRP | S_IWOTH)) */
if (file_info.st_mode & S_IWOTH)
suphp_log_error("Script (%s) is writeable by others", script_path);
return 0;

return 1;

Then, we rebuilt the package simply by
miguel@wn-ss01:/tmp/rebuild/suphp-0.5.2$ debuild -us -uc
dpkg-buildpackage: source package is suphp
dpkg-buildpackage: source version is 0.5.2-3
dpkg-buildpackage: source maintainer is Emmanuel Lacour
dpkg-buildpackage: host architecture is i386
�fakeroot debian/rules clean
/usr/bin/make clean
dpkg-deb: building package `suphp-common' in `../suphp-common_0.5.2-3_i386.deb'.
dpkg-deb: building package `libapache-mod-suphp' in `../libapache-mod-suphp_0.5.2-3_i386.deb'.
dpkg-deb: building package `libapache2-mod-suphp' in `../libapache2-mod-suphp_0.5.2-3_i386.deb'.
dpkg-genchanges: not including original source code in upload
dpkg-buildpackage: binary and diff upload (original source NOT included)

It’s done, the package is rebuilt! Next we just issue dpkg to install our package as root.
developer@dev:/tmp/rebuild/suphp-0.5.2$ cd ..
developer@dev:/tmp/rebuild$ ls
libapache-mod-suphp_0.5.2-3_i386.deb suphp-common_0.5.2-3_i386.deb
libapache2-mod-suphp_0.5.2-3_i386.deb suphp_0.5.2-3.diff.gz suphp_0.5.2-3_i386.changes
suphp-0.5.2 suphp_0.5.2-3.dsc suphp_0.5.2.orig.tar.gz
developer@dev:/tmp/rebuild$ su
dev:/tmp/rebuild# dpkg -i libapache2-mod-suphp_0.5.2-3_i386.deb suphp-common_0.5.2-3_i386.deb

That’s all. Enjoy!