How to change the document root for the primary domain of a cPanel account.
Related Articles
Modify Document Root for Addon Domain
Change Document Root for Primary Domain
IMPORTANT: This solution is only available on VPS and Dedicated hosting plans.
- SSH into the relevant server as root
- Edit both
/var/cpanel/userdata/userna5/domain.comand/var/cpanel/userdata/userna5/domain.com_SSL
REPLACE: userna5 with the cPanel user and domain.com with the primary domain. -
Change
documentroot: /home/userna5/public_htmlandpath: /home/userna5/public_html/cgi-bintodocumentroot: /home/userna5/new_doc_root_dirandpath: /home/userna5/new_doc_root_dir/cgi-binREPLACE: userna5 with the cPanel user and new_doc_root_dir with the new document root.
EXAMPLE: The document root for imhkmc5 was updated from public_html to public_html/public, a common request for Laravel sites. - Rebuild Apache
/scripts/rebuildhttpdconf - Restart Apache
/scripts/restartsrv_httpd --graceful - If using PHP-FPM, edit
/var/cpanel/userdata/userna5/domain.com.php-fpm.yaml
REPLACE: userna5 with the cPanel user and domain.com with the domain. -
Change
php_admin_value_doc_root: /home/userna5/public_htmltophp_admin_value_doc_root: /home/userna5/new_doc_root_dirREPLACE: userna5 with the cPanel user and new_doc_root_dir with the new document root.
NOTE: If the line does not exist, add it.
EXAMPLE: - Rebuild PHP-FPM
/scripts/php_fpm_config --rebuild - Restart PHP-FPM
/scripts/restartsrv_apache_php_fpm - If NGINX is installed
- Rebuild ngxconf
ngxconf -u userna5 -rdF && ngxutil -Xu userna5
REPLACE: userna5 with the cPanel username. - Restart NGINX
systemctl restart nginx
- Rebuild ngxconf
Comments
0 comments
Article is closed for comments.