Bobcares

For every $500 you spend, we will provide you with a $500 credit on your account*

BLACK FRIDAY SPECIAL

*The maximum is $4000 in credits, Offer valid till December 6th, 2024, New Customers Only, Credit will be applied after purchase and expires after six (6) months

For every $500 you spend, we will provide you with a $500 credit on your account*

BLACK FRIDAY SPECIAL

*The maximum is $4000 in credits, Offer valid till December 6th, 2024, New Customers Only, Credit will be applied after purchase and expires after six (6) months

cPanel – change root directory with these easy steps

by | Oct 25, 2018

Your website defines the personality of your online business. Many website owners require a lot of customization, features and tweaks to get their desired site.

In our role as Outsourced Tech Support services for web hosts, account related issues or requests are one common category of tasks that we handle.

cPanel root directory aka Document root – Why do you need to change it?

Document root aka cPanel root directory is the default directory in which your website files are stored. These files show up when you access the site via browser.

When you create a domain in your cPanel/WHM server, the document root for that domain would be ‘/home/user/public_html’ directory by default.

While this is usually fine for most website owners, during certain special scenarios, they may need to change this folder to some other directory.

These include installing some third party applications which have custom data folders, configuring URL shorteners, testing different sets of applications or configurations for your site.

cPanel – change root directory in these 4 ways

There are 4 ways to change cPanel root directory and the option we choose varies based on the website’s requirement.

1. Using Addon domains

cPanel offers a feature for website owners to create ‘Addon domains’ from their control panel. Addon domain is a domain that points to a subfolder in the main domain.

Addon domains are configured for customers who prefer to create multiple domains within a single account. They look like independent domains to visitors.

The document root for a domain depends on the type of a domain. For main domain, it is ‘/home/user/public_html’ and for addon domain, it is  ‘/home/user/public_html/sub-folder’.

But cPanel offers a feature where website owners can change the default document root for addon domain during creation or after creating it from the cPanel.

 

Change root directory during Addon domain creation

 

To change the root directory of Addon domain, in the cPanel -> “Domains” section, click the Addon Domain and update the new document root in the popup window.

 

Change cPanel root directory of Addon domain

 

 

2. Creating symlinks

At times, you may already have another directory which you need to set as your document root. This is usually applicable while testing a new site.

To change cPanel root directory in such cases, we backup the current public_html and then create a symbolic link from the desired directory to public_html.

The folder permissions and ownership and related links in pages have to be properly configured in such scenarios, for the site to work fine after the change.

3. Setting redirects

A commonly used technique for changing cPanel root directory is to set redirects from the public_html to the desired folder which contains the files to be displayed.

Setting redirects also help to avoid duplication, especially if the same content has to be shown in different sites or subdomains.

The redirection is set by adding a ‘.htaccess’ in the folder to be redirected and then adding appropriate rewrite URL rules to point to the desired directory.

4. Updating cPanel files

cPanel/WHM does not have an option to change the document root of the main domain via any interface. By default it is the public_html folder in the user home directory.

In certain rare scenarios, we have customers who want their document root to be changed to another folder than public_html.

This has to be done from the backend by updating the cPanel user account file at /var/cpanel/userdata/username/domainname .

The following parameters are updated with the desired directories.

documentroot: /home/steinknu/public_html 

 scriptalias: 
   - 
     path: /home/steinknu/public_html/cgi-bin/

 

For sites with SSL installed, the configuration file for SSL is also updated accordingly.

This file is available at the location /var/cpanel/userdata/username/domain_SSL .

After making the changes, the user data cache is updated and Apache configuration file is rebuilt to reflect the changes in the corresponding files.

The Apache and PHP-FPM services are restarted and we verify the relevant configuration files to ensure that they are all updated properly.

Conclusion

Account customization and feature updates are common requests that come from customers of cPanel/WHM server owners. Today we saw how our Support Engineers help website owners change cPanel root directory.

 

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

SEE SERVER ADMIN PLANS

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF