Introduction

Managing file permissions is a critical part of maintaining a secure web server environment. When using suPHP, security is tightened by enforcing strict ownership and permission rules for files and directories. While this helps prevent unauthorised access and script execution, it can also lead to unexpected issues—most commonly the 500 Internal Server Error—if permissions are not configured correctly.

1. Fix Directory Permissions

Run the following command to set correct permissions for all directories inside public_html:

find /home/*/public_html -type d -exec chmod 755 {} \;

2. Fix PHP File Permissions

Set proper permissions for all PHP-related files:

find /home/*/public_html -name '*.php' -o -name '*.php[345]' -o -name '*.phtml' | xargs chmod -v 644

3. Fix File Ownership

Incorrect ownership can also trigger suPHP errors. Create a script to fix ownership across all cPanel users.

Create Script

fix-permissions.sh

Add the following content:

#!/bin/bash
cd /var/cpanel/users
for user in *
do
  chown -R $user:$user /home/$user/public_html/*
done

Make it executable:

chmod +x fix-permissions.sh

Run the script:

./fix-permissions.sh

Conclusion

suPHP adds an important layer of security by ensuring that scripts run under the correct user with safe permission settings. However, even small misconfigurations can break websites and cause frustrating server errors.

By applying the fixes outlined in this guide—correcting directory permissions, adjusting file permissions, and ensuring proper ownership—you can quickly restore website functionality while keeping your server secure. Regularly auditing permissions and avoiding overly permissive settings like 777 will help prevent these issues from recurring.

Leave a Reply