CAll Us: World: +1 541 678 7323 | India: +91 86686 23778
How to Host Only Subdomain in Cpanel at Different Host?

How to Host Only Subdomain in Cpanel at Different Host?

At times there might be possibility that you would like to host Sub Domain eg. subdomain.yourdomain.com at different server than your current server where you have hosted your main domain eg. yourdomain.com.

Lets assume you would like to host a Forum which is quite resource intensive script and thus requires to have it hosted at either different hosting account or a VPS.

So you have your main domain “yourdomain.com” hosted at Server 1 and you would like to host forum “forum.yourdomain.com” subdomain at Server 2

This can be achieved easily by following below steps. For better understanding we will use below names.

yourdomain.com – Primary Domain

forum.yourdomain.com – Sub Domain

Step 1

Log in to your Primary Domain’s Hosting Account, Edit DNS Zone of your Primary Domain and Add an ‘A’ entry for the Sub Domain pointing to Server2 Main IP Address.

You need to find your 2nd Server’s Main IP Address which can be easily done by pinging any existing domain hosted at Server2.

To ping existing domain hosted at Server 2 you can use this command from Command Prompt

“ping your2nddomain.com” which will expose the Server IP Address.

If you find it difficult to run ping command then you can simply head over to the website Whatsmydns.net , enter any another domain hosted at 2nd Server, Select  A  from drop down list and hit search, you will get your 2nd Server IP Address, note it down.

If you still find it difficult then you can simple ask your Hosting Provider to provide you a Server’s Main IP Address.

Example of an entry to be added.

forum.yourdomain.com –  A  – 14400(TTL Value)  – xx.xx.xx.xx (2nd Server Main IP Address)

Step 2

Before hosting Sub Domain, we need to make sure that the new entry is properly added in DNS Zone and to verify that we can use website Whatsmydns.net Enter your subdomain, Select  A from the drop down list and hit search to see the IP Address which is resolving  for your Sub Domain.

If its same as your 2nd Server Main IP Address, Bingo you have successfully added DNS Entry for Sub Domain

Step 3

Now head over to your 2nd Server and log in to WHM / Cpanel, if you would like to host this Sub Domain as stand alone account then you can use WHM – > Create Account function or if you would like to add it as Add On Domain then you can go to Cpanel – > Add on Domain to host this subdomain.

In both the cases simply enter your complete Sub Domain eg. forum.yourdomain.com and fill out rest of the info, once done you can hit the Create button.

Depending upon propagation time, once done you can see that your Sub Domain is successfully hosted at 2nd Server. To verify that you can simply create a test html file in Document Root of your Sub Domain eg. public_html following Cpanel – > File Manager and by browsing relative path of file eg. forum.yourdomain.com/test.html from your favorite browser.

How to Fix Ownership of cPanel accounts Server wide?

In order to fix the ownership of all cPanel users server wide, you need to execute below Shell script

If you are having a Shared Hosting or Reseller Hosting account then you need to get in touch with your Hosting Provider to fix ownership issue as the below script will fix ownership of all cPanel accounts server wide.

If you have a shell access to your cPanel Server you can use below method to fix ownership issue server wide.

Login to Shell and execute below commands

# vi fixowner.sh

Copy below script in Editor and Save it

#!/bin/bash
echo -e “Checking ownership of /home/user n”
for i in `ls /var/cpanel/users/`
do
if [ “$i” != “root” ]; then
chown -R $i:$i /home/$i
chown $i:nobody /home/$i/public_html /home/$i/.htpasswds
chown $i:mail /home/$i/etc /home/$i/etc/*/shadow /home/$i/etc/*/passwd
echo $i
fi
done

Assign 755 executable permission to your Script with below command

# chmod 755 fixowner.sh

Now run script to fix Ownership of user accounts server wide.

# ./fixowner.sh

Now you will notice that Ownership issue of server wide cPanel accounts has been fixed