[WHM/cPanel] Changing Home directory

What is the document root?

When you visit a website, you are accessing a particular folder on the web server. The server knows to only serve up those files located at that folder to incoming visitors. The location of that web folder is called the “Document Root”.

For example, when you visit DOMAIN.COM, the server is pulling up the files at: /home/USERNAME/public_html. The document root is set by the Apache configuration.

What we are going to discuss today is what if you wanted to change that location? You would need to change the ‘Document root’ for the domain. WHM/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 WHM/cPanel.

Changing Primary domains

For changing the main/primary domain, you will need to have root SSH access. Edit the following (replacing your user & domain info):

/var/cpanel/userdata/USERNAME/DOMAIN.COM

1. Once you have opened the file, look for the following line:
documentroot: /home/USERNAME/public_html

2. Modify the location according to your needs. Save it and exit.
documentroot: /home/NEW-USERNAME/public_html

3. Open the following file:
/etc/passwd

4. Modify the following line accordingly to your need:
USERNAME:x:907:906::/home/NEW-USERNAME:/bin/bash

5. Rebuild the Apache conf and reload Apache configuration:

/scripts/rebuildhttpdconf
service httpd graceful

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, feel free to open up a support ticket and we’ll be happy to help.

  • 7 Users Found This Useful
Was this answer helpful?

Related Articles

[WHM/cPanel] CloudLinux PHP selector not saving on cPanel 54 and CL 6.x & 7.x

Problem:When trying to change php extensions in paper_lantern, nothing saves. I can click Save or...

[WHM/cPanel] Update WHM/cPanel using CLI

Occasionally, WHM or cPanel might experience errors that can only be resolved by updating the...

10 Points Server Maintenance Checklist

Server Maintenance Checklist Just like any other computer, Linux servers need periodic...

[EA3] New Relic APM on cPanel & CloudLinux CageFS

Many System Administrators tried to get PHP apps hosted on a cPanel server with CloudLinux and...

Test CRON

You may want to test if the CRON is running on your server.  There is few ways in order to test...