Server Administration & Management

How to Pointing a sub-domain to folder outside public_html in cPanel

When you create a sub-domain, cPanel points it to the corresponding folder under public_html by default. How to point it to a folder outside the public_html, This cannot be done via cPanel/WHM but can be achieved if you have ‘root’ SSH access to the server.

1. Open the apache configuration file — /etc/httpd/conf/httpd.conf
2. Search for the virtual host entry for your sub-domain.
3. Edit the document root of your sub-domain to match the desired location.
4. Save and Exit. Restart apache.

Note: cPanel rebuilds httpd.conf from userdata files and its overwritten on every cPanel update, on every account creation, subdomain addition, or any such activity related to apache & any manual changes you make will be overwritten. To make permanent changes to a subdomain’s root folder :

1. Edit the file /var/cpanel/userdata/username/subdomain.domain.com file, change the path and save it.
2. Run /scripts/rebuildhttpdconf
3. Restart apache.

July 16, 2012 Posted by | cPanel | , | Leave a comment