Changing the Document Root for Your Domain InMotion Hosting ContributorUpdated on January 9, 2025 3 Minute Read InMotion Hosting is able to change the Document Root location where your Primary Domain points to. This allows the file structure to be maintained as the developer has referenced the files in the website’s code. This article will explain how to get the document root changed for your primary domain. VERY IMPORTANT: Changing a primary domain’s document root is NOT RECOMMENDED by InMotion Hosting. cPanel backup and restore packages use the default settings and will NOT save your document root changes. For instance, if the cPanel account is moved or restored, the document root change will no longer exist, which may cause your website to behave unexpectedly. Accounts on Shared Servers Shared server accounts cannot change their Primary Domain’s document root, because root access is not allowed on Shared servers. Our Technical Support can change the document root on your Shared server account per your request. You will need to submit this in a verified ticket request to Support with the following details included: Domain to update document root for. Full path to the directory location you want to change the document root to. VPS and Dedicated Servers Steps to Change the Document Root (with root access) When a VPS or Dedicated server customer needs to make a document root change, they can do so with Root Access. The steps below will explain how to change the document root of the primary domain, with root access. VERY IMPORTANT: InMotion Hosting does not support changes made by customers as the ‘root’ user. Any time required by the System Administration team to repair, troubleshoot, or restore services due to changes made (as a result of having root access) may be subject to billing charges. This does not guarantee resolution of technical issues deemed outside the scope of our support. ssh [email protected] Edit the following file: /var/cpanel/userdata/USER/DOMAIN NOTE: If you have an SSL certificate installed (for the domain you are modifying the document root directory for), you WILL need to edit the following file as well: /var/cpanel/userdata/USER/DOMAIN_SSL Notice the files’ contents are similar to the output below. The areas to edit are indicated by RED text. Note: the “path:” line is only present in the non-SSL file. If you have an SSL, both files will need to be edited. - customlog: - format: combined target: /usr/local/apache/domlogs/domain.com - format: ""%{%s}t %I .\n%{%s}t %O ."" target: /usr/local/apache/domlogs/domain.com-bytes_log documentroot: /home/USER/public_html group: USER hascgi: 1 homedir: /home/USER ip: 123.45.67.89 owner: root phpopenbasedirprotect: 1 port: 80 scriptalias: - path: /home/USER/public_html/cgi-bin url: /cgi-bin/ serveradmin: [email protected] serveralias: www.domain.com servername: domain.com usecanonicalname: 'Off' user: USER Change the following lines in the file: documentroot: /home/USER/public_html path: /home/USER/public_html/cgi-bin The changes will look like the following: documentroot: /home/USER/public_html/new_doc_root_dir path: /home/USER/public_html/new_doc_root_dir/cgi-bin When finished editing the document root, run the following scripts while logged in as the root user, to rebuild and restart Apache: /scripts/rebuildhttpdconf systemctl restart httpd This ensures that your changes are updated in the Apache configuration and will allow the changes to apply immediately. NOTE: When using PHP-FPM as the PHP handler for your server, you will need to restart the PHP-FPM service as well. To restart PHP-FPM services run the following commands: /scripts/restartsrv_cpanel_php_fpm /scripts/restartsrv_apache_php_fpm Changing the Document Root (without root access) VPS and Dedicated customers that do not have root access cannot change the document root of their main domain. VPS and Dedicated server customers without root access will need to follow the same process as the Shared server customers. Share this Article Related Articles How to Change the Primary Domain in cPanel How to Transfer a Domain Name to InMotion Hosting SPF and DKIM Records: Combating Spam How to Add/Cancel Domain Privacy in AMP Registering a New Domain Name How to Park a Domain in cPanel How to Change Your Domain Nameservers in AMP How To Fix the “DNS Server Not Responding” Error on Windows and Mac Wildcard Subdomains and DNS How to Create a Subdomain in cPanel