Report this

What is the reason for this report?

I want to change root directory of "public_html" to public

Posted on March 1, 2021

I went to WHM Terminal and trying to change root of “public_html” by this code “/var/cpanel/userdata/username/domain.com” it showing permission denied, So how I can solve this issue ?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there,

As you may know, directly modifying the Apache config on a cPanel server is not a good idea as your changes would be lost after the next Apache rebuild.

Also changing the document root for an Addon domain name on a cPanel server is pretty straightforward. However, occasionally you would like to do this for your main domain name as well.

Here’s one of the easy ways on how to do that:

You would need root shell access and then follow these simple steps:

Open the following file:

nano /var/cpanel/userdata/your-cpanel-user/your-domain.com

Modify the documentroot accordingly:

documentroot: /home/your-cpanel-user/public

Then rebuild your Apache config file

/scripts/rebuildhttpdconf

Run a config test

apachectl -t

If you get Syntax OK, then restart Apache:

systemctl restart httpd

Hope that it helps. Regards, Bobby Source

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.