When you visit a web site, you are accessing a particular folder on a web server. For example, when you visit johns-carpentry.com, 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 simply want to reorganize. In any case, I’ll show you how to make that change on cPanel.
Changing Addon Domains
There are two types of domains on a cPanel box that can have document roots: Main (primary) domains and Addon domains. Changing the document root for Addon domains is easy. Simply log into your cPanel and navigate to: Domains >> Addon domains.
Next, edit the Addon 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 have opened the file, look for the following line:
2. Modify the location according to your needs. Save it and exit.
3. Rebuild the Apache conf and restart Apache:
/scripts/rebuildhttpdconf 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