Cpanel is not giving me option to change the root directory for one of my domains
Stefan Bogdanescu
Founder & Senior Architect · 2026-06-29
Mastering Document Roots on VPS: How to Change Your Domain Directory When cPanel Fails You
As a senior developer working with VPS environments, you often encounter situations where the control panel interface, while convenient, limits the necessary granular configuration. Today, we are diving into a very common scenario: needing to adjust the document root directory for a domain—a necessity when deploying modern frameworks like Laravel—and finding that cPanel doesn't offer the direct option you need.
If you are running a CentOS-based VPS and need precise control over where your web application files reside, we need to look beyond the GUI and dive into the core server configuration via SSH.
Understanding the Limitation: Why cPanel Seems Restrictive
You mentioned that in your cPanel interface, you cannot find an option to change the root directory, only system core settings. This is often due to how cPanel manages its environment. It handles most standard configurations through Virtual Hosts and specific file managers. When a domain is set up, the document root (public_html) is tied directly to that setup. Directly editing system files like Apache configuration can lead to instability or being overwritten by cPanel updates, which is why you saw the warning: "the current config doesn't need to be changed or updated because it can be overridden."
This limitation points us toward the most powerful tool available on a VPS: direct command-line access.
The Developer Solution: Modifying Apache Configuration via SSH
Since you are running CentOS 7.9, you have full root privileges via SSH. We will use this access to manually ensure that your Virtual Host configuration correctly points to your desired directory, bypassing any limitations in the cPanel interface. This approach gives us total control and ensures persistence across updates.
Step 1: Locate the Virtual Host Configuration File
In a standard CentOS/Apache setup managed by cPanel, your domain configurations are typically stored within the Apache configuration structure. The main configuration files are usually found under /etc/httpd/conf.d/.
For a specific domain, the relevant configuration is often tied to the Virtual Host definition. You need to inspect the configuration file associated with your domain.
Step 2: Modifying the Document Root
Instead of directly editing core files haphazardly, we focus on the Virtual Host file or the specific directory mapping if possible. For a standard setup, you might look for the configuration block related to your domain.
If you need to change the root for a site named example.com, you would typically modify the DocumentRoot directive within that Virtual Host configuration.
Here is a conceptual example of what a modified Apache configuration snippet looks like (Note: Actual paths and syntax depend heavily on your specific cPanel installation structure, but this illustrates the principle):
<VirtualHost *:80>
ServerName example.com
DocumentRoot /home/user/public_html_new_location <-- Change this line!
ErrorLog /var/log/httpd/example.com_error.log
CustomLog /var/log/httpd/example.com_access.log
</VirtualHost>
Step 3: Applying Changes and Restructuring for Laravel
When preparing for a Laravel installation, you want your web accessible directory to map directly to the framework's public folder (e.g., public). If you move your application files into a custom location outside the standard /public_html, you must ensure Apache knows where to look.
A robust approach is often to use SSH to manage file permissions and then verify configuration:
# Example of moving files (use appropriate paths!)
sudo mv /home/username/old_root/* /home/username/new_laravel_root/
# Ensure correct ownership for web server access
sudo chown -R apache:apache /home/username/new_laravel_root/public
This manual process, when done correctly via SSH and verified against the Apache configuration, is far more reliable than relying solely on GUI options. As experts in modern PHP deployment, understanding these underlying server mechanics is crucial for optimizing performance and deployment workflows, much like ensuring proper structure when setting up an application environment from resources like those provided by Laravel Company.
Conclusion: Control Through Command Line
The takeaway here is that while cPanel provides excellent tools for management, true deep configuration and complex restructuring—especially on a VPS running CentOS—require the power of the command line. By mastering SSH access to understand how Apache Virtual Hosts function, you gain the ultimate control over your server environment. Don't hesitate to use this power; it is the foundation of advanced system administration!