How to Change the Document Root for Your cPanel Primary Domain Name

How to Change the Document Root for Your cPanel Primary Domain Name

 

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 straight forward. 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:

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

    • Modify the documentroot accordingly:

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

    • Then rebuild your Apache config file

/scripts/rebuildhttpdconf

    • Run a config test

service httpd configtest

    • If you get Syntax OK, then restart Apache

service httpd restart

This is pretty much it. Hope that it helps.

Materialize

The Real-Time Data Platform for Developers

Buy me a coffeeBuy me a coffee