Pages

Friday, February 16, 2024

Suphp Installation

Installing suPHP on a server using cPanel and EasyApache is a straightforward process but requires careful attention to detail. suPHP is a tool for executing PHP scripts with the permissions of their owners, enhancing the security of the server. Here's a detailed guide on how to install and configure suPHP:

Step 1: Launch a Screen Session

Before you start, it's recommended to run EasyApache within a screen session. This ensures that the process continues running even if your SSH session is interrupted.
screen -S ea
This command starts a new screen session named "ea."
Step 2: Run EasyApache

Now, initiate the EasyApache script. This script provides a text-based interface for configuring Apache and PHP.
/scripts/easyapache
Step 3: Select Mod SuPHP

Within the EasyApache interface, navigate to the "Exhaustive Options List" and find "Mod SuPHP." Select it by pressing the spacebar. Make any other adjustments as needed for your server environment, then proceed to compile and build Apache and PHP with your new settings.

Step 4: Build the Configuration

After selecting Mod SuPHP and any other required options, follow the on-screen instructions to complete the build process. This might take some time depending on your server's specifications and the options selected.
Step 5: Configure suPHP

Once EasyApache has finished building, you can enable suPHP on your server with the following command:
/usr/local/cpanel/bin/rebuild_phpconf 5 none suphp 1

This command sets PHP5 to use suPHP as the PHP Handler and enables suEXEC, which is necessary for suPHP to function correctly.
Step 6: Verify the Configuration

To ensure that suPHP has been correctly configured, use the following command to display the current PHP handler setup:
/usr/local/cpanel/bin/rebuild_phpconf --current

You should see output indicating that PHP5 is using suPHP and that suEXEC is enabled.
Step 7: Restart Apache

For the changes to take effect, restart the Apache service:
/scripts/restartsrv_httpd
Step 8: Check suPHP Log and Adjust Permissions

Finally, you can check the suPHP log file for any errors or messages:
/usr/local/apache/logs/suphp_log
If you encounter errors related to file permissions, suPHP requires directories to have 755 permissions and files to have 644 permissions. Use the following commands to set permissions correctly for PHP files and directories within your web content:
find . -type d -exec chmod 755 {} \; find . -type f -exec chmod 644 {} \;
Run these commands within the root directory of your website(s).

Conclusion

Following these steps will install and configure suPHP on your cPanel server, enhancing the security by executing PHP scripts with the permissions of their owners. Be sure to monitor the suPHP log file for any errors and adjust file permissions as necessary to avoid common issues related to improper file permissions.

No comments:

Post a Comment