Script to correct the ownership and permisions for suphp cpanel server

After the suphp installation some sites showing internal server. So I have created script to remove php_value in htaccess file and correcting the ownership and permission.

#!/bin/bash

cat /etc/trueuserdomains |cut -d: -f2 >user
for i in `cat user`
do

find /home/$i/public_html/ -iname "*.php" -exec chmod 644 {} \;
find /home/$i/public_html/ -type d -perm 777 -exec chmod 755 {} \;
chown -R $i:$i /home/$i/public_html/
chgrp nobody /home/$i/public_html
chmod 750 /home/$i/public_html
echo "Permission of User $i corrected"

done

for i in `cat user`
do

grep -iRl php_value /home/$i/public_html/ |grep .htaccess >/ht_files
grep -iRl php_flag /home/$i/public_html/ |grep .htaccess >>/ht_files

for h in `cat /ht_files`
do

sed -i 's/^php_flag/#php_flag/g' $h
sed -i 's/^php_value/#php_value/g' $h
done
echo "htaccess file corrected for User $i "
done
Script to correct the ownership and permisions for suphp cpanel server

Leave a Reply

Your email address will not be published. Required fields are marked *

Fork me on GitHub