Server Administration & Management

How to Pointing a sub-domain to folder outside public_html

Issue : 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?

Solution : 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

# vi /usr/local/apache/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.

# /etc/init.d/httpd restart

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 and 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.

# vi /var/cpanel/userdata/username/subdomain.domain.com

2. Run /scripts/rebuildhttpdconf

# /scripts/rebuildhttpdconf

3. Restart apache.

# /etc/init.d/httpd restart

October 13, 2011 - Posted by | Apache, DNS | , ,

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: