Before diving in, make sure you have your affairs in order:
- You have a web server, right?
- Root access to your server via SSH (Learn More)
- You are using Parallels Plesk Panel 10.4 (not Cpanel or anything else).
- A general understanding of Unix Bash commands and working giant screens full of text.
If this sounds like you, keep reading. Now some bullets about the author:
- Media Temple (dv) Dedicated-Virtual 4.0
- Parallels Plesk Panel v10.4.4_build1013111102.18
- CentOS 5 on Linux 2.6.18-028stab099.3
- SSH, iTerm.app on OSX
- A big comfy arm chair in a quiet room.
If you are using a different version of Plesk, the official documentation should have extensive notes about the difference between versions. I imagine much of it is about the same though, if you’re anywhere near version 10.4.
Enough with the formalities. Let’s bash it up.
All Plesk utilities are located in the
psa directory on your machine. For me, that’s
To get a quick snapshot of what’s available, take a peek at the directory contents.
To execute any command, simply navigate to it and enter the instructions. It looks something like this:
/usr/local/psa/bin/<UTILITY> --<COMMAND> -<OPTION1> <PARAM> -<COMMAND2> <PARAM>
For all the utilities I’ve bothered to investigate, these are the most common commands.
--create --add --update --info --help --delete --remove
These functions have corresponding short forms for those of you with lazy fingers and/or tiny screens:
-c # same as --create -a # same as --add -u # same as --update -i # same as --info -h # same as --help -d # same as --delete -r # same as --remove
So if you’re into the whole brevity thing, just
/usr/local/psa/bin/ and start with
./ followed by the utility name, then the short form of the command, and enter your instructions. Here’s what it looks like:
cd /usr/local/psa/bin/ ./UtilityName -x -<OPTION1> <PARAM> -<COMMAND2> <PARAM>
It would be great if there was a consistent convention for
--remove, so be sure to scope the Using Command Line Utilities section of the Parallels documentation and figure out exactly what command goes with a given utility. Looking at the big picture, though, I’m just stoked break away from using a browser-based GUI for trivial server admin tasks. There are also plenty of utility-specific commands, so if you’re unsure or feel like something’s missing, you know where to look.
We have arrived at the moment of truth. This is the part of the article where, in exchange for your hard work and dedication, you are rewarded with some plug & play examples to start things off nice and proper. I’ll assume you’ve
cd-ed into the appropriate directory by now. Let’s go:
We’ll start off nice and easy. Type this to get info about the admin (you).
Hey look, it’s like your Facebook profile, minus that embarrassing photo you were tagged in at that party. Neat!
Ok, now another easy one to get warmed up. To view PHP settings for a certain domain, type:
./site --show-php-settings example.com
Zzzzzzz … OK, moving on….
Managing Email Accounts
Here’s a hot topic: email boxes. Let’s make one:
./mail --create [email protected] -passwd 'user pass' -mbox_quota -1 -mailbox true
This creates the account [email protected] with password ‘user pass’ and sets the mailbox quota to whatever is the default. There is a “gotcha” with the create function: don’t forget to enter
-mailbox true or the account won’t be functional!
Now let’s say we want to change the password on the box we just created to something more secure…
./mail --update [email protected] -passwd 'som3thingm0res3cure'
Or change the email address to John’s full name…
./mail --rename [email protected] -new JohnDoe
Just in case of any confusion, let’s cover our bases with some aliases!
./mail --update [email protected] -aliases add:JohnathanDoe,JDoe,JDizzle
Logging in to webmail and setting up imap can be a pain, so let’s forward John’s email to his gmail account.
If John is on vacation, just set up an auto-responder with the
./autoresponder --update bbvacation -mail [email protected] -subject "I'm in Bora Bora!" ```-text "I won't be checking email until January 1. For urgent matters, please call at 555-555-5555 and leave a message." -status true
When John gets back, update the
-status parameter to turn off the “bbvacation” auto-responder.
./autoresponder --update bbvacation -mail [email protected] -status false
Another must-have. To make an additional FTP account, use the
ftpsubaccount utility like so:
./ftpsubaccount --create JohnDoe -passwd 'userpass' -domain example.com
Now user JohnDoe can login via FTP and access the main site directory for example.com (but nothing higher up or adjacent). To lock the JDow down to a specific directory within, run
--update and pass the
-home option and a directory path relative to the site root (not your server root):
./ftpsubaccount --update JohnDoe -home directory/path/here
Here’s one of my personal favorites. When I need to create a database, that usually means I’m building out a new CMS-based site, and don’t want to be distracted. Stopping everything to open Plesk, log in, navigate to the “Database” section, and fill out the forms required to create the a db and add users is not conducive to development eudæmonia. Plus there’s just something stereotypically satisfying about creating a database from a command prompt. Let’s make a MySQL database called “example_db” on example.com and print its ID upon completion.
./database --create example_db -type mysql -domain example.com -print-id
Warning: Make sure the
-domain is a primary domain for one of your subscriptions. You can’t use just any domain from your account.
Now, what good is a database without a user? Let’s give JDoe access.
./database --update example_db -add_user JDoe -passwd samplepass
And don’t forget Jane, the out-of-office developer on 18.104.22.168.
./database --update example_db -add_user Jane -passwd samplepass ./database --update example_db -update_user Jane -passwd samplepass -add-access 22.214.171.124
Uh-oh - Jane went rogue. Let’s revoke that remote access ASAP, then remove her user account.
./database --update example_db -update_user Jane -passwd samplepass -remove-access 192.0.2.78 ./database --update example_db -remove_user Jane
Subscriptions, Users, & Sites
In Plesk, “subscription” refers to and individual “power panel” (admin panel, control panel, et al) that is granted only enough access to administer certain domains and related tasks. Subscriptions come with a separate user and login credentials, and are owned by another user (usually you, the main server admin).
For a benevolent serving of data on Plesk subscriptions, check out this Media Temple Knowledge Base article.
To start a new subscription based on the domain example.com with the service plan “Unlimited” with a login of “subadmin_name”, run this command:
./subscription --create example.com -owner admin -service-plan "Unlimited" -ip 126.96.36.199 -login subadmin_name -passwd 'userpass'
To add another domain to the example.com subscription, use the
./site --create anotherdomain.com -webspace-name example.com -hosting true
To add example.net with the “standard forwarding” hosting type, redirecting all traffic to example.com, pass the
-hst_type option when you create the site.
./site --create example.net -webspace-name example.com -hosting true -hst_type std -target_url example.com
To create a user account for webmaster Mary, who will manage websites of JDoe:
./user --create [email protected] -owner JDoe -passwd sample -cname Mary -role webmaster
With your newfound expertise in Linux server administration, I’ll leave you with some other choice utilities to get the administrative juices flowing.
--create NAME -domain example.com -hard_quota 1G -ssi true -php true -ssl true -cgi true -fastcgi true -perl true -asp true -python true -coldfusion true
--update NAME -domain example.com -hard_quota 1G -ssi true -php true -ssl true -cgi true -fastcgi true -perl true -asp true -python true -coldfusion true
--update NAME -domain example.com -new_name forum
--remove -subdomains NAME1,NAME2 -domain example.com
This nifty little utility allows you redirect both web and mail service from the alias domain to the hosted domain.
./domalias --create examplealias.net -domain example.com -status enabled -mail true
With this configuration, any visitors to examplealias.net will be redirected to example.com, and any mail sent to [email protected] will be forwarded to [email protected], if it exists on the hosted domain.
Here’s another utility that seems made for the command line. Need to protect a directory real quick? Use the
./protdir --create Protected_Dir -domain example.com -add_user JDoe -passwd userpass -type cgi
-type parameter of ‘nonssl’, or ‘ssl’ for site-level security, or a use ‘cgi’ for root-level security.
There are also a bunch of utilities I haven’t listed, including a lot related to the business/reselling tools included in Plesk. If that’s your alley, be sure to read through the Using Command Line Utilities section of the Plesk CLI docs and see what you can do.