What's new

Welcome to GloTorrents Community

Join us now to get access to all our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, and so, so much more. It's also quick and totally free, so what are you waiting for?

Ask question

Ask Questions and Get Answers from Our Community

Answer

Answer Questions and Become an Expert on Your Topic

Contact Staff

Our Experts are Ready to Answer your Questions

Change Primary Domain Document Root in cPanel/WHM

_.:=iTake=:._

Administrator
Staff member
ZeuS
Super Moderator
+Lifetime VIP+
Registered
Joined
Oct 20, 2018
Messages
1,370
Reaction score
1,431
Points
113
Credits
14,854
The cPanel accounts are created using a primary domain. All primary domains on the hosting account use “public_html” directory for all its website files and data. The sub-directories inside the public_html directory is occupied by the addon domains. The primary domain can also be setup to use a sub-directory inside public_html directory instead of public_html itself. Follow the below steps to change the document root of your primary domain in cPanel account. Please note that, you will need to have root SSH access to perform these steps.

1) Connect to your server via SSH as root user. You may follow the tutorial below, if you are using a Windows system to connect to your server via SSH. This tutorial explains how to use “Putty”, SSH client software to access server.

2) Using your favorite text editor (say vim) edit the following file.

$ vim /cpanel/userdata/username/domain.com
Replace the “username” with your cPanel account username and “domain.com” with your primary domain name and “subdir” with your new directory. Find the following two lines in this file.

documentroot: /home/username/public_html
path: /home/username/public_html/cgi-bin
Modify these two lines to change the document root of your primary domain to a sub-directory inside “public_html” directory.

documentroot: /home/username/public_html/subdir
path: /home/username/public_html/subdir/cgi-bin
Save the file after changes are made and then delete the cache file for your primary domain.

$ rm -vf /var/cpanel/userdata/username/domain.com.cache
3) If the primary domain has an SSL certificate installed, edit the following file the same way as above.

$ vim /var/cpanel/userdata/username/domain.com_SSL
Save the file after changes are made and then delete the cache file for your primary domain.

$ rm -vf /var/cpanel/userdata/username/domain.com_SSL.cache
4) Run the following scripts to update the user data cache and rebuild apache configuration file.

/scripts/updateuserdatacache
/scripts/rebuildhttpdconf
5) Restart Apache server to load changes.

$ service httpd restart

Source: https://www.interserver.net/tips/kb/change-primary-domain-document-root-cpanelwhm/
 

_.:=iTake=:._

Administrator
Staff member
ZeuS
Super Moderator
+Lifetime VIP+
Registered
Joined
Oct 20, 2018
Messages
1,370
Reaction score
1,431
Points
113
Credits
14,854
this is very useful if Cpanel is messing up and u can't fix issues like this. It's important to rebuild userdata else changes won't take effect..
 
Last edited:

Prom3th3uS

Administrator
Staff member
Junior Administrator
Super Moderator
+Lifetime VIP+
Contributor
Registered
Joined
Oct 21, 2018
Messages
836
Reaction score
321
Points
63
Location
Unknown
Credits
12,458
Thanks for the tut :) Cheers!
 
shape1
shape2
shape3
shape4
shape7
shape8
Top