Monday, 26 September 2011

Fixing File and Folder Permission on suPHP

After installing suPHP on server, the directories which is having the permission more than 755 and files which is having more than 644 will not work in the browser. The browser will show the Internal server error.

For fixing the suPhp error, you can use the following scripts.

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

This command fix all folder permission

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

This command fix all file permission

3. Create a file with the following content and give the executable permission.

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

This script fix all ownership issue.

No comments: