[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

Using dig to Query a Specific DNS Server (Name Server)

There may be occasions when you wish to query a name server directly.  I usually do it when...

Test CRON

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

[CentOS/RHEL/CloudLinux] rpc.statd is not running but is required for remote locking

Fixing rpc.statd is not running but is required for remote locking   If you come across this...

10 Points Server Maintenance Checklist

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