Jump to content

Change Primary Domain Document Root in cPanel/WHM


Recommended Posts

  • Superior Administrator
Posted

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.

 

[iCODE]$ vim /cpanel/userdata/username/domain.com[/iCODE]

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.

 

[iCODE]documentroot: /home/username/public_html

path: /home/username/public_html/cgi-bin[/iCODE]

Modify these two lines to change the document root of your primary domain to a sub-directory inside “public_html” directory.

 

[iCODE]documentroot: /home/username/public_html/subdir

path: /home/username/public_html/subdir/cgi-bin[/iCODE]

Save the file after changes are made and then delete the cache file for your primary domain.

 

[iCODE]$ rm -vf /var/cpanel/userdata/username/domain.com.cache[/iCODE]

3) If the primary domain has an SSL certificate installed, edit the following file the same way as above.

 

[iCODE]$ vim /var/cpanel/userdata/username/domain.com_SSL[/iCODE]

Save the file after changes are made and then delete the cache file for your primary domain.

 

[iCODE]$ rm -vf /var/cpanel/userdata/username/domain.com_SSL.cache[/iCODE]

4) Run the following scripts to update the user data cache and rebuild apache configuration file.

 

[iCODE]/scripts/updateuserdatacache

/scripts/rebuildhttpdconf[/iCODE]

5) Restart Apache server to load changes.

 

[iCODE]$ service httpd restart[/iCODE]

 

Source:

This is the hidden content, please

  • Like 3
  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

[[Template forums/front/topics/postContainer is throwing an error. This theme may be out of date. Run the support tool in the AdminCP to restore the default theme.]]

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...
×
GloTorrents Community Forum
Home
Activities
Sign In
Search
More
×