Create account in WHM/cPanel from cli

WHM provides a very friendly interface for managing sites, users and databases on the server. Sometimes you have to create several hundreds of accounts for different clients (for example, migrating from a regular server to WHM). In this case you can spend weeks on mouse clicks in the web interface.

In this case it is much easier to create accounts using prepared WHM shell scripts. In this particular case wwwacct will help us.

To create an account account with password password for the site websitename.com, use the following command:

/scripts/wwwacct **websitename.com** **account** **password**

Create database in mysql console:

create database account_dbname;
grant all privileges on **account_dbname**.* to **account_dbuser**@localhost identified by '**password**';

Link the mysql database and the user with the newly created account:

/usr/local/cpanel/bin/dbmaptool **account** -type mysql -dbs '**account_dbname**'
/usr/local/cpanel/bin/dbmaptool **account** -type mysql -dbusers '**account_dbuser**'

Categories: ,

Updated: