How to Change the Apache Default Document Root on a cPanel Server

By default, cPanel configures Apache to load its default website from /usr/local/apache/htdocs.  This page will redirect to the template of the default page that is set up by cPanel, which is configurable via WHM -> Web Template Editor.

If you want to change the location of the default site altogether, you’re going to need to modify one of the EasyApache templates.   This particular modification is easy to do:

cd /var/cpanel/templates/apache2/

cp main.default main.local

 

The main.default is used to build the structure of the entire httpd.conf, which in turn also pulls in other templates from various locations.  When you copy this to main.local, you’re telling EasyApache to use the .local file instead.  If the main.local already exists, you can probably just edit the existing version.

In this file, you’re looking for a defined VirtualHost entry that starts with this:


<VirtualHost [% vh %]>
ServerName [% servername %]
DocumentRoot [% serverroot %]/htdocs

 

You’ll want to change the DocumentRoot setting to the location of the files you want to serve.  You may also need to set SuPHP_UserGroup to the user/group of the cPanel account that owns the files.  Here’s a DocumentRoot example:

 

DocumentRoot /home/user/public_html/

 

Once you’ve changed this, run the following to apply your settings:

/scripts/rebuildhttpdconf

service httpd reload