[HowTo] Install suPHP On Ubuntu

suPHP is a tool for executing PHP scripts with the permissions of their owners. Along with the Apache module mod_suphp it allows Apache to process PHP with the user’s permission. This will improve security. With suPHP you can track which users use the most resources.

Follow the steps below to install suPHP on Ubuntu:

1. Open your terminal with root permission

2. Type this command:

apt-get install libapache2-mod-suphp

3. Wait until it is finished, and you are done.

See how it works in action:

Manual installation for other Linux distributions:

1. Open your terminal with root permission

2. Disable PHP5 module, you need to edit httpd.conf:

vim /etc/httpd/conf/httpd.conf
#note the location may be vary in different Linux distributions.

Then disable PHP5 module:

#LoadModule php5_module modules/libphp5.so

3. Install suPHP prerequisite:

yum install php-cli httpd-devel #For CentOS and Fedora
#OR
apt-get install php5-cgi apache2-prefork-dev #For Debian and Ubuntu

4. Download and build suPHP:

cd /tmp
wget http://www.suphp.org/download/suphp-0.7.1.tar.gz
tar xvfz suphp-0.7.1.tar.gz
cd suphp-0.7.1/
./configure --prefix=/usr --sysconfdir=/etc --with-apr=/usr/bin/apr-1-config --with-apxs=/usr/sbin/apxs --with-apache-user=apache --with-setid-mode=paranoid --with-php=/usr/bin/php-cgi --with-logfile=/var/log/httpd/suphp_log --enable-SUPHP_USE_USERGROUP=yes
make
make install

5. Add this to httpd.conf:

LoadModule suphp_module modules/mod_suphp.so

6. Restart Apache:

/etc/init.d/httpd restart #For CentOS and Fedora
/etc/init.d/apache2 restart #For Debian and Ubuntu

That’s it, now when Apache executes your PHP script it will execute with the user’s permissions.