[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

What are .htaccess files and how to create and edit them

.htaccess files are used to configure and provide the server with instuctions regarding the...

Recommended firewall

What firewall do you recommend to secure my Linux server? MACI recommends the CSF (ConfigServer...

10 Points Server Maintenance Checklist

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

[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...

Installing GeoIP (PECL) on WHM

In order to install GeoIP via PECL on a WHM enabled server, you must first install 2 modules:1)...