BuycPanel Blog

BuycPanel Blog

Latest news and updates

1/20/2015 – Change a Document Root in cPanel

Posted by Jamison on 20 01 2015.

Every web page or website that you visit has a particular storage. Every time you go to a website, you are actually accessing through series of folders where that page you are visiting is located. This location is called document root. This holds true when you are looking for a file on your computer that is stored at a specific folder. You keep on looking for the file, folder after folder until you reach the origin of its location.

 

If you are using cPanel on your website, sometimes you want to change the document root settings—you may want to reorganize and de-clutter your website. This article will show you how to do this.

 

Two types of domains that you can change document root are Addon and Main domain. Let’s discuss Addon domains first. Here’s how.

 

Changing Document Root for a Subdomain or an Addon

 

To change the document root on addon is much simpler than changing for the main domain. And it’s done in just three simple steps.

 

  1. Open you cPanel account and look for Domains, then click on Addon Domains. This will open the Modify Addon Domain page.
  2. Edit the domain path by clicking the edit icon under the Document Root column. Look for the document root you wish to change. Beside this path or link is the edit icon. Click it and a pop-up window will appear.
  3. Enter the document root you wish to put your files or webpages on and then click Change.

 

And that’s it! Simple and literally effortless.

 

Changing Document Root for the Main Domain

 

Now for the primary domain, there are two ways to do this—1) by changing the domain name as the root user; and 2) by getting root access and rewriting the URL. Let’s discuss the first one.

 

  1. You need to be more careful when changing the domain name as this could damage your file. You might even need to contact your hosting provider before doing this. To start, login to your account and look for View Hosting Packages. Select the one that you want to change and then click Change My Domain. Register a new name and you are done.

 

Please note that the new name should not be identical with any of your domains.

 

  1. The second process will need you to have root SSH access so you can edit or rewrite the URL. No you don’t necessary need ample knowledge of coding. Just follow this simple trick below. And oh! Please make sure that your SSH’s template is updated.

 

  1. Login to your cPanel account.
  2. To gain shell access, you can simply use SSH. Right now you should be looking a URL such as this: /var/cpanel/userdata/USERNAME/DOMAIN.COM_SSL
  3. Enter your cPanel’s account name replacing Username and then enter your main domain name replacing domainname.com
  4. Now, look for Text Documentroot and then start making your necessary changes. The document root should be looking like this: /home/USERNAME/public_html
  5. Now change the URL with /home/USERNAME/public_html/NEW_PATHà change username and new_path accordingly.
  6. After it’s done, you need to rebuild Apache and restart its server. Follow this for the exact command:

# /scripts/rebuildhttpdconf

# service httpd restart

  1. Changes will be made immediately and be permanently updated.

 

Yup! The latter process may seem a little complex, but actually it’s not. Just carefully follow these directions and you’ll be fine. Good luck!