Question

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

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 ?


Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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