How to install suPHP on DirectAdmin

Posted at January 28, 2017 at 11:40 am by Jithin

In this tutorial we can learn how to install suPHP on DirectAdmin

 

The suPHP is a tool for executing PHP scripts with the permission of their owners, which means that the suPHP can control who can access a certain file. It consists of a mod_suphp module of apache. Since most PHP scripts run as ‘nobody’ user, which means any users of the server can execute the file and give them the ability to add code to URL and manipulate the file accordingly. The suPHP is a solution for this problem, that suPHP will stop PHP running as user ‘nobody’, so the files can be only written by the user allowed for that file.

 

Advantages of using suPHP

1) It provides better security.

2) It will make any PHP application such as Mambo more user friendly.

3) Can define custom php.ini file for different users.

4) It doesn’t allow world writable file (777).

DirectAdmin is a control panel for web hosting management through that administrator can manage websites easier. And it is compatible with servers like CloudLinux, Red Hat, CentOS, Ubuntu, etc. By default, the DirectAdmin came with php as CLI option. All the PHP scripts will run as a user ‘apache’.  The suPHP gives better security than the mod_php module of apache webserver, as it run the php files under the account user instead of default user ‘apache’. The DirectAdmin custombuild provides simple way to enable the suPHP on DirectAdmin control panel.

 

Installation of suPHP

1) Login as root user to the DirectAdmin server. And go to the directory /usr/local/directadmin/custombuild by using the following command.

# cd /usr/local/directadmin/custombuild/

 

2) Run below custombuild scripts to change the DirectAdmin settings.

# ./build clean

# ./build update

# ./build set php5_cgi yes

# ./build set php5_cli no

# ./build all d

# ./build rewrite_confs

After these scripts run on the server, the suPHP will be installed on the server.

 

3) Once the installation of suPHP is completed, you will need to fix the phpMyAdmin, Roundcube, squirrelmail. For that run below command.

# ./build roundcube

# ./build squirrelmail

# ./build phpmyadmin

 

4) Now fix the permissions of all the files and directories of the users by running the below given scripts.

# 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

 

Possible errors

1) Users will see message that ” Apache functioning normally” instead of actual website.

Solution:

Run the following command as root user.

# cd /usr/local/directadmin/custombuild/

# ./build rewrite_confs

2) Apache wouldn’t start with following error 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

 

Solution:

Run the following command as root user.

# ./build suphp

# ./build rewrite_confs

 

If you need any further assistance please contact our support department.

 

 

0.00 avg. rating (0% score) - 0 votes

You can skip to the end and leave a response. Pinging is currently not allowed.

Leave a Reply