Cpanel / SuPHP fix permissions

Here are a few one liners to change the perms needed when switching to suphp. The following commands will look in every user’s html folder and make the appropriate chmod to allow php to properly execute under SuPHP.

* For Directories
find /home/*/public_html/ -type d -print0 | xargs -0 chmod 0755
* For Files
find /home/*/public_html/ -type f -not -name "*.pl" -not -name "*.cgi" -not -name "*.sh" -print0 | xargs -0 chmod 0644
* For CGI/Scripts
find /home/*/public_html/ -type f -name "*.cgi" -print0 -o -name "*.pl" -print0 -o -name "*.sh" -print0 | xargs -0 chmod 0755
  
Don’t forget to check for files owned by ‘nobody’ or ‘root’ — they will also fail with a 500 error. The following Perl script will eliminate nobody/root ownership. Place the Perl script into your /home directory and execute it.

#!/usr/bin/perl -w

my @dirs = grep -d,< *>;

foreach my $user (@dirs) {
`chown -R $user:$user $user/public_html/*`;
}

g33kadmin

I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....