Permission error in /home directory CentOS 6.9 running WHM/Cpanel

I have a dedicated server running CentOS 6.9 and WHM/Cpanel

Sometime ago I ran two commands as following

chgrp -R shahzaib-ftp /home
chmod -R g+w /home

I am able to run cpanel and WHM but no website from any cpanel account is working. Can you please help me to setup correct owner and permissions? To see error visit aubdesign.com.au website for example.

Your web server unable to view dirs and files. So you get 403 error. There is no easy way. Do you have backups? Restore it. If not here are two ways:

1.Command run as root:

find /home/*/public_html/* -type f -exec chmod 644 {} \;
find /home/*/public_html/* -type d -exec chmod 755 {} \;
for i in $(ls /var/cpanel/users) ; do chown -R $i.$i /home/$i/public_html/* ; done

2.A script to fix permissions & ownership, on files & directories, for cPanel accounts.

To get the fixperms script, simply wget the file from GitHub and make sure it’s executable:

wget https://raw.githubusercontent.com/PeachFlame/cPanel-fixperms/master/fixperms.sh
chmod +x fixperms.sh

Fixing one single user/account

Then, run it (with ROOT permissions) while using the ‘a’ flag to specify a particular cPanel user:

sh ./fixperms.sh -a USER-NAME

It does not matter which directory you are in when you run fixperms. You can be in the user’s home directory, the server root, etc… The script will not affect anything outside of the particular user’s home folder.

Fixperms - for all of the users

If you would like fix the permissions for every user on your cPanel server, simply use the ‘-all’ option:

sh ./fixperms.sh -all

I think script method is safe and reliable. Try it out. Always keep backups.

2 Likes

Thanks a lot. You are a champ. It was certainly giving me headache.

Good to know your issue has been resolved. Be careful in future. Always keep full backups and never run commands like that again.