In this article we'll discuss an advanced method for taking a single cPanel account, and splitting it into multiple cPanel accounts. Multiple cPanel accounts are only available on VPS or dedicated server plans, and splitting up your domains between multiple cPanel accounts can allow you to give away cPanel access to a website owner without having to give the end user access to your other domains.

In our example below we have one cPanel account with the name userna1 that has the primary domain name PrimaryDomain.com and an addon domain name called AddonDomain.com. We want to break apart these two domains so we can give a web developer full cPanel and FTP access to AddonDomain.com without them being able to modify anything on our PrimaryDomain.com site.

We have a WordPress install on both domains, so we will also need to take special care to ensure that the MySQL database gets moved over and the database user credentials are modified to allow the database connection to still work with a new username.

To follow along with these instructions you would need root access to your server. If you don't have root access you can also follow along with our more basic article on how to split a single cPanel account into multiple ones.

  1. Login to your server via SSH as the root user.
  2. We want to find the document root for our AddonDomain.com and then change to that directory with these commands:

    grep addondomain.com /etc/userdatadomains

    Which should give us back:

    addondomain.com: userna1==userna1==addon==addondomain.primarydomain.com==/home/userna1/public_html/addondomain.com==70.39.151.52:80==

    Now change to the directory in-between the =='s with:

    cd /home/userna1/public_html/addondomain.com

  3. Now we want to look for any database configurations on this domain, an easy way is to look for the username followed by an underscore _ through all your files with the following command:

    grep userna1_ ./ -RH

    Which should give back something similar to:

    ./wp-config.php:define('DB_NAME', 'userna1_wrdp1');
    ./wp-config.php:define('DB_USER', 'userna1_wrdp1');

    So we can see because of wp-config.php that these database credentials are for a WordPress site, you'll want to open up this file and also copy down the DB_PASSWORD value as well as the DB_NAME and DB_USER ones.

  4. Now we want to backup that WordPress database to our home directory using the following command:

    mysqldump userna1_wrdp1 > ~userna1/userna1_wrdp1.sql

  5. We can now create our new cPanel account. The first thing you'll want to do is Log into WHM.
  6. In the top-left Find box type in Create, then click on Create a New Account.
    cpanel-click-on-create-new-account
  7. Now for the Domain: you'll want to enter your domain with a -temp.com suffix, that way we can test and get the account up and running prior to shutting down the real site. So in our example we're using AddonDomain-temp.com, you can then choose a username and password you'd like this new cPanel to use, and in the Choose a Package drop-down you'll want to select the default vpspackage or whatever custom package you might have set up.

    After entering in all the information scroll to the bottom of the page and click on Create

    cpanel-enter-temp-domain
  8. Now that the new account is created we want to copy over all of the relevant files for the AddonDomain.com site to the new userna2 account with the following series of commands:

    rm -rf ~userna2/public_html

    cp -frp ~userna1/etc/addondomain.com ~userna2/etc/

    cp -frp ~userna1/mail/addondomain.com ~userna2/mail/

    cp -frp ~userna1/mail/.*@addondomain_com ~userna2/mail/

    cp -frp ~userna1/public_html/addondomain.com ~userna2/public_html

    Now we want to fix the permissions of all the files we brought over, so they're owned by the userna2 user with the following command:

    fixperms userna2

  9. Now we want to update our wp-config.php script so it's using our new userna2 username, this can be done with the following command:

    replace userna1_ userna2_ -- ~userna2/public_html/wp-config.php

    Which should spit back:

    /home/userna2/public_html/wp-config.php converted

  10. Now Login to your cPanel so you can create the MySQL database.
  11. Under the Databases section click on MySQL Database Wizard.
    cpanel-click-on-database-wizard
  12. Enter in the database name from our wp-config.php script, then click on Next Step.
    cpanel-create-a-database
  13. Enter in a database username and password, then click Create User.
    cpanel-create-a-database-user
  14. Place a check beside All Privileges, then click Next Step.
    cpanel-database-privileges
  15. Now back to our SSH session we can import our MySQL backup into the newly created userna2_wrdp1 database with the following command:

    mysql -u userna2_wrdp1 -p userna2_wrdp1 < ~userna1/userna1_wrdp1.sql

    At the Enter password: prompt, enter in the database user password you copied down earlier.

  16. Now you'll want to login to your original cPanel account again to remove the AddonDomain.com from the account, so that we can modify the one we created on our new account.

    To start this process under the Domains section click on Addon Domains.
    cpanel-click-on-addon-domains
  17. Beside AddonDomain.com click on Remove.
    cpanel-addon-domain-remove
    On the confirmation screen click on Remove "AddonDomain.com".
  18. Now that the domain is removed from our userna1 cPanel account, we'll want to log back into WHM so we can modify our userna2 account to use that domain.

    In the top-left Find box type in modify, then click on Modify an Account.
    whm-click-on-modify-an-account
  19. Click on our AddonDomain-temp.com domain, then click on Modify.
    whm-select-addon-click-modify
  20. Now change the domain entry in the Primary Domain: field to AddonDomain.com, then scroll to the bottom and click on Save. You should see a green Success! status display when it's done.

This should be all that is necessary for splitting one cPanel account into multiple cPanel accounts. Once you have everythign running correctly on the new separate cPanel account, you can then go back to the original userna1 cPanel account and remove the AddonDomain.com site's files from /etc/addondomain.com, /etc/addondomain.com, and /public_html/addondomain.com. Also you can remove the MySQL database from that user as well now that a duplicate copy has been setup under our new userna2 user.

Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve this article:
Email Address
Name

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Like this Article?

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

News / Announcements

WordPress wp-login.php brute force attack
Updated 2014-07-17 06:43 pm EST
Hits: 200900

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!