Fix the chmod/403 issue of "public_html" directory

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:

[[email protected] ~]# 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
[[email protected] ~]#

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.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to fix defaultwebpage.cgi on a webserver

Running the following commands solves the above problem:   /scripts/updateuserdomains...

How to fix IP Missing issue on cPanel/WHM

We are here to help you with solving the problem of Missing IP Server in list accounts. The...

Install Let's Encrypt SSL in cPanel/WHM

Let's Encrypt, a valid, open-source license that offers free SSL for your domains. The Let's...

Fix Email Issue on a server using the MSFE

To solve the problem of not sending/receiving email on a server using the MSFE / Mailscanner...

Domain names are not showing in WHM

We were unable to see any domains listed under WHM -> List Accounts. However, we can see the...