Changing a Document Root in cPanel

When you visit a web site, you are accessing a particular folder on a web server. For example, when you visit, the server is pulling up the files at: /home/johnc/public_html. The web server only serves up the files located at that folder to incoming visitors. The location of that web folder is called the “document root”.

It is similar to using a coat check. You present your ticket to the attendant and they fetch it from the back room. The visitor doesn’t know the exact location where the coat is stored, but the coat does reside at a specific location.

That specific location of the web folder is the document root and is set by the Apache configuration.

But what if you wanted to change that location? cPanel’s default location may not serve your needs, or you may simply want to reorganize. In any case, we’ll show you how to make that change on cPanel.

Changing Add-on Domains

There are two types of domains on a cPanel box that can have document roots: Main (primary) domains and Add-on domains. Changing the document root for Add-on domains is easy. Simply log into your cPanel and navigate to: Domains >> Add-on domains.


Next, edit the Add-on domain path. To do so, simply click the “Edit” icon next to the path, and type in your new path.


It’s that simple!

Changing Primary domains

For changing the main/primary domain, you will need to have root SSH access, and be able to locate and edit the following file (replacing your user & domain info):


1. Once you open the file, look for the following line:

documentroot: /home/USERNAME/public_html

2. Modify the location according to your needs. Save it and exit.

3. Rebuild the Apache conf and restart Apache:

service httpd restart

The change will be immediate. Simply clear your browser cache and force refresh the page!

And, of course, if this seems a little too advanced and you’re a ServInt customer, feel free to open up a support ticket in the customer portal, and we’ll be happy to help.

Photo by Steve Gary

Find out more about ServInt solutions

Starting at $25

  1. @Derek Fong, these two methods are actually better than running the distiller because they work within the cPanel template system. When cPanel rebuilds the Apache conf, it builds it based on the template, user profiles, etc... Using these methods will always ensure that your custom directives will always be retained. It is definitely the preferred way to change your document root.
    Jacob "Boom Shadow" Tirey /
  2. Is this method a "blessed" way of customizing a DocumentRoot? cPanel provides a different method using Apache include files (which also involves using the conf distiller to record any changes made to the core httpd.conf file), but this method is by far less clunky.
  3. [...] written for the ServInt blog as part of the ‘Tech bench’ series. You can view it on the ServInt blog here. Used with permission. Related Posts:Fix: Fantastico is not installed at the default [...]
    Change a document root on cPanel | /
  • Hosting Advice
  • Computer World
  • Ars Technica

  • The New York Times
  • The Seattle Times
  • Bloomberg
  • The Hill

To engage with the ServInt Sales Team use the following chat icon. Normal sales hours are Monday-Friday 9am-5pm EST but feel free to leave a message and we will follow up as soon as possible.

Sales Chat

To engage with the ServInt Support Team you must be logged into our Customer Portal for identity verification and have a ticket opened about your request or there will only be limited support offered.

Support Chat