[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

[EA3] New Relic APM on cPanel & CloudLinux CageFS

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

[WHM/cPanel] Update WHM/cPanel using CLI

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

[EA4] New Relic APM on cPanel & CloudLinux CageFS

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

Tweak the swapinness

What is swappiness and why should I change it? swappiness is a value between 0 and 100 which...