When migrating a website from a non-suPHP server to a suPHP-enabled cPanel server, you may encounter permission and ownership errors. This happens because suPHP enforces stricter file and directory permissions for security purposes.

This guide will help you identify the issue and fix it—either manually for individual files or automatically for all users on the server.


⚠️ Common Error After Migration

When accessing a domain, you may see a blank page or internal server error. To diagnose, tail the Apache error logs:

tail -f /usr/local/apache/logs/error_log

You’ll typically see something like this:

[error] SoftException in Application.cpp:601: Directory “/home/user/public_html/test.php” is writable by group.
[error] Premature end of script headers
:

🔍 Understanding the Issue

The error usually means that files or directories are too permissive (e.g., 777 permissions) or owned by the wrong user (like nobody instead of the cPanel user).

Example:

cd /home/user/public_html/
ll | grep test.php

Output:

-rwxrwxrwx 1 nobody nobody 158 test.php

✅ Fix it manually:

chmod 644 test.php
chown user:user test.php


🛠️ Fix suPHP Permissions Server-Wide (Automatic Script for cPanel)

If you’re dealing with multiple accounts, running fixes manually isn’t practical. Here’s a simple shell script that recursively corrects permissions and ownership for all user accounts on a cPanel server.

📄 Step 1: Create the Script

vi /root/suphpfix.sh

Paste the following content:

#!/bin/bash
for user in `ls /var/cpanel/users`; do
echo "Fixing permissions for: $user"
chown ${user}:${user} /home/${user}/public_html
chmod 755 /home/${user}/public_html
find /home/${user}/public_html -group nobody -print0 | xargs -0 chgrp ${user}
find /home/${user}/public_html -type f -print0 | xargs -0 chmod 644
find /home/${user}/public_html -type d -print0 | xargs -0 chmod 755
done

🔒 Step 2: Make It Executable

chmod u+x /root/suphpfix.sh

▶️ Step 3: Run the Script

bash /root/suphpfix.sh

This script loops through all cPanel users, adjusts ownership, and applies proper permissions (755 for directories and 644 for files).


🧯 Final Notes

  • suPHP ensures PHP scripts are executed as the file owner, not as the web server user (nobody), adding a layer of security.
  • Avoid using 777 or group-writable permissions on files/scripts.
  • Always back up before applying bulk permission changes.

By admin