Home > Linux, Plesk, SSH > Add Domain Name to Hosting on Plesk CLI

Add Domain Name to Hosting on Plesk CLI

June 12th, 2012

Hello Dear Readers,
It is the Summer season and I finally have more time to post stuff right after I do it.
Today I had to create a new domain in hosting under Plesk control panel command line and since I never kept notes for the previous times I did it, I had to undergo some documentation reading.
The best resources online are provided by Parallels themselves. It is one of the most well documented APIs that I have come across in the hosting world, have to give them that!
The URL is http://download1.parallels.com/Plesk/PP10/10.1.1/Doc/en-US/online/plesk-unix-cli/index.htm
All I had to do is issue the following two commands in order to create the domain in hosting and then to create a database related to it:

1. Creating a new domain name in Hosting on Plesk CLI

[root@216-55-186-14 bin]# /usr/local/psa/bin/domain --create domainname.me -owner Client1 -ip -status enabled -hosting true -hst_type phys -dns false -login domain_user -passwd temp_pass -shell /bin/bash -cgi false -php true -php_safe_mode true

The above command creates hosting for the domain name domainname.me in the hosting account of Client1.
It assigns the IP address of to the domain name, enables the hosting, etc.
The nicest thing is that it creates a Linux user domain_user with SSH access (shell /bin/bash) and ftp access.

2. Creating MYSQL database for the domain name on Plesk CLI

[root@216-55-186-14 bin]# /usr/local/psa/bin/database -c db1 -domain domainname.me -type mysql --add_user db1_user -passwd db1_user_pass

The above line invokes the database command which creates a new MYSQL database with name db1.
It also creates a new mysql user db1_user, granted access to the database with password of db1_user_pass.
By default the user will have access to the database only through localhost. If you wish to make changes to the access for the user, you have to either explore the -add-access option of the database command or manually edit the MYSQL.USER table as you probably already know.

When the above tasks are completed the domain name is fully functional and the newly created user can start by connecting to the server, uploading website content and manage the mysql database.
In my case I simply used mysql do import an sql backup of the database I needed. Then rsync to move the httpdocs content from one server to another.
In order to test the website on the new server without having to actually change it’s DNS A records I simply changed my hosts file and added a record for the domain name.
Only after performing a thorough test of the migrated site I feel comfortable to request a DNS update.

Hope this helps,


Categories: Linux, Plesk, SSH Tags:
Comments are closed.