[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 Kasutajad peavad seda kasulikuks
Kas see vastus oli kasulik?

Seotud artiklid

Freeing Space

Problem: Is there a way to tell the kernel to give back the free disk space now? Like a write to...

crontab management

crontab is a command line tool in order to manage your cron tasksThe two most important basic...

Recommended firewall

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

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