How to change `documentroot` in cPanel?

I have searched how to do this for a long time, finally I could fix all problems in my projects about documentroots.

This is actually so easy to do:

1) Head to the settings directory of the user your want to edit

cd /var/cpanel/userdata/USER/

2) Edit the following file/s:

   /var/cpanel/userdata/USER/DOMAIN

Important! If you have an SSL certificate on the account, you may need to edit the following file as well.

   /var/cpanel/userdata/USER/DOMAIN_SSL

You should see the files like this:

 -
   customlog:
 -
       format: combined
       target: /usr/local/apache/domlogs/domain.com
 -
       format: "\"%{%s}t %I .\\n%{%s}t %O .\""
       target: /usr/local/apache/domlogs/domain.com-bytes_log
   documentroot: /home/USER/public_html # Here!
   group: USER
   hascgi: 1
   homedir: /home/USER
   ip: 123.45.67.89
   owner: root
   phpopenbasedirprotect: 1
   port: 80
   scriptalias:
 -
       path: /home/USER/public_html/cgi-bin # Here!
       url: /cgi-bin/
   serveradmin: webmaster@domain.com
   serveralias: www.domain.com
   servername: domain.com
   usecanonicalname: 'Off'
   user: USER
Change the following lines in the file:

documentroot: /home/USER/public_html path: /home/USER/public_html/cgi-bin

The changes will look like the following:

documentroot: /home/USER/public_html/new_doc_root_dir path: /home/USER/public_html/new_doc_root_dir/cgi-bin

3) When finished editing the document root, run the following scripts while logged in as the ROOT user:

   /scripts/rebuildhttpdconf
   service httpd graceful

Copyright © Ozan Kurt 2015.

Scroll to Top