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:


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


You should see the files like this:

       format: combined
       target: /usr/local/apache/domlogs/
       format: "\"%{%s}t %I .\\n%{%s}t %O .\""
       target: /usr/local/apache/domlogs/
   documentroot: /home/USER/public_html # Here!
   group: USER
   hascgi: 1
   homedir: /home/USER
   owner: root
   phpopenbasedirprotect: 1
   port: 80
       path: /home/USER/public_html/cgi-bin # Here!
       url: /cgi-bin/
   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:

   service httpd graceful

Copyright © Ozan Kurt 2015.

Scroll to Top