How to install suPHP on DirectAdmin using custombuild

This is a useful guide for administrators who manage directadmin servers. Administrator sometimes wants to change the php handler to suphp  instead of deafult mod_php. SUphp provides better protection to server than mod_php as it runs the php scripts under the user account instead of of default user apache.

DirectAdmin custombuild provides a very simple way to achieve this. Please follow the below steps to get this done.

cd /usr/local/directadmin/custombuild/
./build set php5_cgi yes
./build set php5_cli no
./build all d
./build rewrite_confs


Once suphp is installed on the server. User will need to fix phpMyAdmin, Roundcube and squirrelmail.

./build roundcube
./build squirrelmail
./build phpmyadmin


Now administrators can fix the permissions of all the files and folders of the users.

for i in `/bin/ls /usr/local/directadmin/data/users/` ; do chown -R $i.$i /home/$i/domains/* ; echo $i ;done 
for i in `/bin/ls /usr/local/directadmin/data/users/` ; do find /home/$i/domains/ -type f -exec chmod 644 {} \; ; echo $i ;done
for i in `/bin/ls /usr/local/directadmin/data/users/` ; do find /home/$i/domains/ -type d -exec chmod 755 {} \; ; echo $i ;done


One more thing to keep in mind -> Sometimes after installing suphp, websites on the server may not be working properly

Users can see message "Apache is functioning normally" instead of actual websites.

To fix this issue follow the final step.

./build rewrite_confs

Possible errors

You might encounter the following issues:
Apache wouldn't start with the following message:

Starting httpd: httpd: Syntax error on line 17 of /etc/httpd/conf/httpd.conf: Syntax error on line 1 of /etc/httpd/conf/extra/httpd-phpmodules.conf: Cannot load /usr/lib/apache/mod_suphp.so into server: /usr/lib/apache/mod_suphp.so: cannot open shared object file: No such file or directory

The solution is very simple

./build suphp
./build rewrite_confs
Scripts wouldn't load in the browser with the following message:
 UID of script "/home/username/domains/domain.com/public_html/index.php" is smaller than min_uid


Now you are done. Enjoy!

Was this answer helpful? 126 Users Found This Useful (158 Votes)