There may have been times when you need to give cPanel access to a website owner or a web developer for a particular domain. But how do you do that without giving end-user access to other domains on that cPanel account? By splitting a single cPanel account into multiple ones. In this article, we’ll walk you through the process of splitting up your domains between multiple cPanel accounts in a seamless way.
In the tutorial, we will be splitting the cPanel account with the name arvinduser that has the primary domain name example.com and an addon domain name called newdomain.com. We aim to split the cPanel account so that we can provide full cPanel and FTP access to newdomain.com without any modification to the example.com site.
Follow the simple steps mentioned below to split your single cPanel account seamlessly:
- Log into your server as the root user using SSH.
- First, we need to find the document root for our addon domain (newdomain.com). We do that to shift to that directory with the following commands:
grep newdomain.com /etc/newdatafolder
The output should be:
newdomain.com: arvinduser==arvinduser==addon==newdomain.example.com==/home/ arvinduser/public_html/newdomain.com==12.34.567.89:80==
Now, change to the directory given in the output. Enter the following command:
cd /home/arvinduser/public_html/newdomain.com
- Being in the same directory as the document root of the add-on domain, we can now look for the database configurations on the domain. The simple way to find the database configurations is by looking for the username followed by an underscore ( _ ) through all the files. Write the following command:
grep arvinduser_ ./ -RH
It should give you an output along the lines of:
./wp-config.php:define('DB_NAME', 'arvinduser_wpdb'); ./wp-config.php:define('DB_USER', 'arvinduser_wpdb');
Clearly, these database credentials are for a WordPress site as we see wp-config.php in the output. We want to open this file and note the database credentials down, including DB_NAME, DB_USER, DB_PASSWORD.
- Before creating the new cPanel account, we better back up that WordPress database to our home directory. Enter the following command to do that:
mysqldump arvinduser_wpdb > ~arvinduser/arvinduser_wpdb.sql
Now, log in to your WHM for creating your new cPanel account.
- Search for ‘Create’ in the top-left Find search bar, and click on Create a New Account.
- In the Domain field, we will be entering the domain with a -temp.com suffix. This gives us a way to test and set up the account and get it running before shutting down the real site. We are using newdomain-temp.com as the example. Enter the username and password that you want the new cPanel account to have. Finally, in the Choose a Package drop-down, either go with the default VPS package or choose a custom package according to your preferences. Hit Create after filling in all the information.
- We will now transfer all of the relevant files for the newdomain.com site to the new newuserarvind account. Enter the following series of commands:
rm -rf ~newuserarvind/public_html cp -frp ~arvinduser/etc/newdomain.com ~newuserarvind/etc/ cp -frp ~arvinduser/mail/newdomain.com ~newuserarvind/mail/ cp -frp ~arvinduser/mail/.*@newdomain_com ~newuserarvind/mail/ cp -frp ~arvinduser/public_html/newdomain.com ~newuserarvind/public_html
With that, all the relevant files of newdomain.com are brought over to the newuserarvind account. However, the new account still doesn’t own them. Enter the following command to fix the commands for the files:
fixperms newuserarvind
- Now that you’ve fixed the permissions, you now need to update the wp-config.php script for it to use the new newuserarvind username. Enter the following command to do so:
replace userna1_ userna2_ -- ~userna2/public_html/wp-config.php
The output that you should get is:
/home/newuserarvind/public_html/wp-config.php converted
- You now need to create a MySQL database for the new cPanel account. Log into your cPanel.
- Click on the MySQL® Database Wizard under the DATABASES section.
- You will be asked to enter the details for the database to be created. Enter the database name extracted from the wp-config.php script. Then, Hit the Next Step button.
- Next, you will be asked to create database users. Enter a database username and password and then click on Create User.
- In the next step, you need to assign privileges for the database user. Check the All Privileges checkbox and proceed by clicking on Next Step.
- Now, you need to import the MySQL backup into the newly created newuserarvind_wpdb database. For that, go back to the SSH session and enter the following command:
mysql -u newuserarvind_wpdb -p newuserarvind_wpdb < ~arvinduser/arvinduser_wpdb.sql
You should see a prompt that asks you to enter the password. Enter the database password that you noted down.
- Finally, you can remove the addon domain from the original cPanel account. Login into the original cPanel account. Under the Domains section, click on Addon Domains.
- You will find newdomain.com listed in Addon Domains. Click on the Remove button beside it. Confirm it on the confirmation prompt by clicking on Remove “newdomain.comâ€.
- Now that the addon domain is removed from the original arvinduser cPanel account, we can proceed to modify our newuserarvind account. For that, log back into WHM. Enter the query “modify†into the top-left Find box, and then click on Modify an Account.
- Select the newdomain-temp.com domain in the Account Selection window, then hit Modify.
- In the Primary Domain field, change the domain name to newdomain.com. Then, scroll to the bottom and hit the Save button.
And there we go! You should see a green Success! status display once you’re done with the last step. We have successfully a single cPanel account into two and can now easily give access to someone to the addon domain.
- Know about the best wordpress web hosting by clicking here.