Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ercanertan/0c70d5f42944501fe8690fcdc75edd53 to your computer and use it in GitHub Desktop.
Save ercanertan/0c70d5f42944501fe8690fcdc75edd53 to your computer and use it in GitHub Desktop.
WHM/cPanel - Changing an accounts document root

To properly edit an accounts DocumentRoot go to /var/cpanel/userdata/username/ (replace username with the actual cPanel username for the account), then edit the file domain.com (where domain.com is your primary domain name).

You will see something like this in that file:

documentroot: /home/username/public_html

You will also see the cgi-bin area in this section:

scriptalias:
  -
    path: /home/username/public_html/cgi-bin
    url: /cgi-bin/

Simply change both to the right path, then save the file. At that point, copy your existing httpd.conf file, rebuild Apache, then restart Apache. Your site will then start serving from the new document root.

Here are the commands to do those:

cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak02121014
/scripts/rebuildhttpdconf
/etc/init.d/httpd restart

You can also look at /etc/httpd/conf/httpd.conf at that point to see it now has the changed DocumentRoot line and cgi-bin path.

@ercanertan
Copy link
Author

cd /var/cpanel/userdata/website/

nano /var/cpanel/userdata/website/website.com

Update document root Same step for SSL

After Run scripts
/scripts/updateuserdatacache
/scripts/rebuildhttpdconf

Restart Apache
service httpd restart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment