Fix the chmod/403 issue of "public_html" directory Print

  • 0

Hello, one of our clients reported us recently, some of his websites can't be accessed. He gets the message: 403 Forbidden. He checked, ModSec isn't triggering it. Then he contacted us, and we found that chmod aka permissions of "public_html" was wrong, it was 000. We tried to change it from the File Manager and CLI but failed. Then, we've able to fix the issue after checking RPMs, perls. Here's the solution for you:

Run the command to get the lists with the cPanel accounts having the issue:

for i in `cat /etc/trueuserdomains | awk '{print $2}'`
do
chown $i.$i /home/$i -R;
chown $i.mail /home/$i/etc -R;
chown $i.nobody /home/$i/public_html;
chmod 750 /home/$i/public_html;
done;

The output would be like that:

[root@server71 ~]# for i in `cat /etc/trueuserdomains | awk '{print $2}'`
> do
> chown $i.$i /home/$i -R;
> chown $i.mail /home/$i/etc -R;
> chown $i.nobody /home/$i/public_html;
> chmod 750 /home/$i/public_html;
> done;
chown: changing ownership of ‘/home/cpuser01/public_html’: Operation not permitted
chmod: changing permissions of ‘/home/cpuser01/public_html’: Operation not permitted
chown: changing ownership of ‘/home/cpuser02/public_html’: Operation not permitted
chmod: changing permissions of ‘/home/cpuser02/public_html’: Operation not permitted
chown: changing ownership of ‘/home/cpuser03/public_html’: Operation not permitted
chmod: changing permissions of ‘/home/cpuser03/public_html’: Operation not permitted
[root@server71 ~]#

Here's you can see, the issue on the accounts: cpuser01, cpuser02, and cpuser03.

Now, to change attribute, run:

chattr -i /home/username/public_html

Do not forget to replace "username" with the origin cPanel username.

At last, to fix the issue of chmod/permissions of public_html, run the command first command of the topic.


Was this answer helpful?

« Back

Send Message