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:

[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.

  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

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...

Domain names are not showing in WHM

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

How to Start/Stop or Restart Apache server

Apache is the HTTP server that is freely available over the internet. It is a kind of software or...

How to install Attracta SEO Tools plugin

RequirementscPanel/WHM needs to be installed on your server. Step 1: SSH into your server and go...

How to Install CpCleaner in cPanel through SSH?

Installation Run the following shell commands as root via SSH: wget -O cpc-1.0.3.tar...