Linux : How to change the DocumentRoot of the primary domain of a cPanel account

By | October 2, 2015

This quick procedure will show you how to change the DocumentRoot (usually public_html) to a custom path/folder.

First, make sure the directory exist and that the user have the appropriate read-write permissions.

Then edit the user data file (by replacing the user and domain value to match yours) :

vi /var/cpanel/userdata/<USER>/<DOMAIN.TLD>

Locate the following statement :

documentroot

(It should be something like “documentroot: /home/<USER>/public_html/”)

Change it to the new desired path and/or folder name. Example :

documentroot: /home/<USER>/public_html/<FOLDER_NAME>/

Rebuild the Apache configuration :

/scripts/rebuildhttpdconf

Restart Apache :

service httpd restart