NEW LOCATION

Olá Brazil Brazil NVMe-powered VPS Plans in Brazil Now Available.

Deploy Instantly
  • +357 2425 0808
  • Login
  • English

Home

Blog

How To Change Document Root of Main Doma...

How To Change Document Root of Main Domain in cPanel

How To Change Document Root of Main Domain in cPanel

NetShop ISP

NetShop ISP · Blog Author

Jul 30, 2024 · Technical Tutorials

Often webmasters and cPanel server admins need to change the document root of the domain which is associated with the main cPanel account. Whilst changing the document root of an addon or sub-domain is a straightforward process, there is no official guideline from cPanel on how to change the document root of an account’s main domain.

NetShop ISP’s Support team have helped numerous customers who requested to change the document root of their main cPanel account, and so we have decided to publish in this article a 100% working solution.

Steps to Change Document Root of Main cPanel Domain

Just follow the next steps for a successful document root change of your account’s main domain name.

Step 1: Take Backup

It’s crucial that before you proceed to the next steps you take a full backup of your cPanel account.

You may do so by copying your home directory somewhere safe within the same server (assuming you have root access) as follows:

root@cpanel:~$ cp -r /home/myuserdir /root/

The above command will copy the entire “myuserdir” directory under /root/ folder.

Alternatively, you can you a reliable, off-site cloud backup software to backup your home directory, such as Acronis.

Step 2: Edit files under /var/cpanel/userdata/$USERNAME

The second step requires to edit two files under /var/cpanel/userdata/$username , where $username is the username of your account in concern. In our example the username is wwwcolocy.

Edit Document Root of cPanel Main Domain (1)

There are two files to edit; the base domain and the SSL one. In our example, the domain in concern is cypruscolo.com so we will edit the two files as follows (we use “vi” as our text editor, you may use your own preferred editor):

root@localhost:~$ vi /var/cpanel/userdata/wwwcolocy/cypruscolo.com

Change the paths as indicated in the screenshot below, then save and exit the file.

Edit Document Root of cPanel Main Domain (2)

Then follow the same process by editing the “documentroot” variable in the corresponding SSL file:

root@localhost:~$ vi /var/cpanel/userdata/wwwcolocy/cypruscolo.com_SSL
Edit Document Root of cPanel Main Domain (3)

Step 3: Delete cache files

As you are in the same directory, there are two cache files as indicated by the screenshot below.

Edit Document Root of cPanel Main Domain (4)

Delete them using the following command:

root@localhost:~$ rm -f /var/cpanel/userdata/wwwcolocy/cypruscolo.com.cache && rm -f /var/cpanel/userdata/wwwcolocy/cypruscolo.com_SSL.cache

Step 4: Update userdatacache and re-build httpd config

You are almost ready. At this point we need to execute the following commands so our changes are applied in the system.

root@localhost:~$ /scripts/updateuserdatacache

Then, execute the following command to re-build apache’s configuration:

root@localhost:~$ /scripts/rebuildhttpdconf

Step 5: Restart Apache

The final step is to restart Apache. Do so by executing the following command:

root@localhost:~$ service httpd restart

You are all set! Congratulations, you have edited the document root of your cPanel’s primary domain name!

Press Releases
75

Free VPS Trial

No Credit Card Required.

Recent Posts

The Critical Role of Server Time Synchronization in MetaTrader 5 (MT5) Cluster

The Critical Role of Server Time Synchronization in MetaTrader 5 (MT5) Cluster

04 September, 2024

NetShop ISP Expands Global Cloud Footprint in São Paulo, Brazil (LatAm)

NetShop ISP Expands Global Cloud Footprint in São Paulo, Brazil (LatAm)

30 August, 2024

Microsoft Security Alert: Zero-Click IPv6 Vulnerability on Windows Servers [CVE-2024-38063]

Microsoft Security Alert: Zero-Click IPv6 Vulnerability on Windows Servers [CVE-2024-38063]

17 August, 2024

How To Connect (RDP) on Windows Server 2022 from Linux Ubuntu PC

How To Connect (RDP) on Windows Server 2022 from Linux Ubuntu PC

16 August, 2024

Web Hosting Choice Criteria for Software Development Companies

Web Hosting Choice Criteria for Software Development Companies

09 August, 2024

#letushostyou

Award Winning Hosting Provider established in 2004.

120 Faneromenis Avenue, Imperial Tower, 2nd Floor, Larnaca 6031, Cyprus

Products

Bare Metal Servers

Customized Servers

Virtual / Cloud Servers

Forex VPS

Storage VPS

cPanel Web Hosting

Reseller Web Hosting

Colocation

Addons

Premium DNS

Email Hosting

Cloud Backup

DDoS Protection

Licenses

SSL Certificates

Domain Names

Premium SLAs

About Us

Data Center Locations

Looking Glass

Our Company

Contact Us

Careers in Cyprus

Become a Partner

Awards

Certifications

© 2024 S.S. NetShop Internet Services Ltd. All rights reserved.  Terms & Conditions  |  Privacy Policy
CY Reg. Number: HE 217340 | EU VAT Number: CY10217340J

Visa
Mastercard
PayPal
Bitcoin
Tether
Ethereum
Litecoin
Wise
Revolut
Wire Transfer