Theme editor

Guide cPanel Changing the DocumentRoot (Root Directory) in cPanel – 2025 Guide

  • Thread starter Thread starter CL4Y
  • Start date Start date
  • Views 138

CL4Y

Keyboard Ninja
Administrator
Thread owner

Changing the DocumentRoot (Root Directory) in cPanel – 2025 Guide​

For projects using frameworks like Laravel, you may need to change your domain’s root directory from the default public_html to public_html/public. Follow the steps below to easily complete this process.



🔧 1. Connect via SSH and Edit the Configuration File​

To access your server via SSH, open your SSH client and run the following commands:

Bash:
cd /var/cpanel/userdata/USERNAME/
nano DOMAIN.COM

  • Replace USERNAME and DOMAIN.COM with your actual account information.

jettor-DocumentRoot-change-1.webp
jettor-DocumentRoot-change-2.webp


Find the following line in the file:
YAML:
documentroot: /home/USERNAME/public_html

Change it to:
YAML:
documentroot: /home/USERNAME/public_html/public

To save and exit: press CTRL + X, then Y, and finally Enter.

jettor-DocumentRoot-change-3.webp




🔁 2. Run the Commands to Apply the Changes​

Execute the following commands in order:

Bash:
/scripts/updateuserdomains
/scripts/updateuserdatacache
mv /etc/apache2/conf/httpd.conf{,.bk}
/scripts/rebuildhttpdconf
/scripts/restartsrv_httpd

Don’t forget to run the commands in the exact order listed above!
 
Thread owner
After completing the steps above, your domain’s root directory will now successfully point to the /public folder.
This structure is especially recommended for projects using frameworks like Laravel, as it provides a more secure and organized setup.

If you encounter any errors after making the changes, check your Apache error logs located at /usr/local/apache/logs/error_log to identify the issue.
You can also share your log details with us for further assistance. 🙂
 
Back
Top