Creating cPanel Subdomains and Addon Domains Outside of public_html

In the world of web hosting and server management, cPanel stands as a titan, offering a user-friendly interface for complex tasks. A common question that arises for both new and experienced users is about the flexibility of domain and subdomain creation. Specifically, can you create subdomains and addon domains outside of the default public_html directory? The answer is a resounding yes, and this article will guide you on how to achieve this and why you might want to.

The Default: Why public_html?

By default, cPanel is configured to restrict the creation of new domains, subdomains, and addon domains to the public_html directory. This is a security and organizational measure, ensuring that all publicly accessible web content is neatly contained in one place. For many users, this is a perfectly acceptable and even desirable setup.

Unlocking Flexibility: Moving Beyond public_html

However, there are numerous scenarios where you might need more flexibility. You might want to:

  • Host non-web-accessible files: Keep certain files or applications separate from your main website’s publicly accessible content.
  • Organize development environments: Create staging or development sites that are not inside the main public directory.
  • Improve workflow: Structure your files and directories in a way that makes more sense for your specific project.

To enable the creation of subdomains and addon domains outside of the public_html directory, you need to have administrator (root) access to your server’s Web Host Manager (WHM).

How to Enable Off-public_html Domain Creation

The process is straightforward for server administrators:

  1. Log into WHM: Access your Web Host Manager with your root credentials.
  2. Navigate to Tweak Settings: In the WHM search bar, type “Tweak Settings” and select the option when it appears.
  3. Find the “Restrict document roots to public_html” Setting: Use the search function within the Tweak Settings page to find this specific option.
  4. Turn it Off: By default, this setting is “On”. To allow the creation of domains and subdomains outside of public_html, you need to set it to “Off”.
  5. Save your changes.

Once this setting is saved, cPanel users on your server will now have the ability to specify a directory outside of public_html when creating new subdomains and addon domains.

Conclusion

While the default cPanel configuration is designed for simplicity and security, a simple tweak in WHM can unlock a new level of flexibility for you and your users. By allowing the creation of subdomains and addon domains outside of the public_html directory, you can better organize your projects, enhance your development workflow, and have greater control over your server’s file structure. This small change can have a big impact on how you manage your web hosting environment, making cPanel an even more powerful tool in your arsenal.