How to Install WP CLI in Plesk Servers

plesk banner

wp cli on plesk and how to install

I’m a self professed Linux geek! can spend all day in a Linux command line and be happy. I can likely setup a LAMP server with my eyes closed, and enjoy every moment of it. Still, managing a production server for a web application can often surprise one, with the amount of upkeep and unexpected surprises.  I found it not only troublesome to install WP CLI on Plesk Servers, but I found the lack of information on how to install WP CLI on Plesk odd.  So I decided to create one!  

how to install WP CLI to Plesk Severs, an instructional guide

Tools like Plesk, Cpanel, Webmin, and more come in handy, when you need them. They greatly help an administrator manage the complexities of a web-server. In addition, one has the added benefit of the community and the support offered by the developers.

While there are many great options for server management software suites, I tend to prefer Parallels’ offering, Plesk. It offers an intuitive graphical user interface for managing your environment, and very powerful command line tools that help even the most knowledgeable admin or developer streamline their work.  So let’s learn how to install WP CLI on a Plesk Server.


WP CLI on Plesk is very helpful but can run into issues when attempting to use on a Plesk Server

Unfortunately, there are times when the very same software can also get in the way. One example I ran head into, when first learning how to install WP CLI to Plesk Servers was being able to utilize the WordPress command line interface tool (WP-CLI) from the Plesk servers command line.

The issue here is, the server attempts to run the WP-CLI utility using the system PHP binary, which as of the time of writing this article, is PHP version 5.4. WordPress and the WP-CLI requires a minimum of PHP 5.6. So, what can we do about this. While, we can consider many possible solutions, I’d suggest utilizing the Plesk WP-Toolkit Plesk extension. Not only will it allow you to run WP-CLI commands without complex modification of your server, or relying on configuring environment variables. It also provides other niceties. I highly suggest adding it to your WordPress on Plesk workflow.

How to Install WP CLI to Plesk Server

First thing we need to do is install both the WordPress CLI, and the WP-Toolkit PLesk Extension. The order of the insall is unimportant here, but I’ll start with the WP-Toolkit extension. This can be easily installed using the Plesk graphical interface, or via the command line. The quickest way would be to simple use the Plesk Extension Manager. We can first check if it’s already installed. Simply list the Plesk extentions you currently have installed.

# plesk bin extension -l

You might notice it’s already installed, like in the following example.

# plesk bin extension -l
advisor - Advisor
composer - PHP Composer
fileserver - Samba Fileserver Configuration
firewall - Firewall
letsencrypt - Let's Encrypt
nodejs - Node.js
repair-kit - Repair Kit
sslit - SSL It!
wp-toolkit - WordPress Toolkit

If you don’t see it, simple use the following command:

# plesk bin extension --install wp-toolkit

Next we’ll look at installing the WordPress CLI. The following command will take care downloading the WP-CLI .phar, moving it into the /usr/bin directory, making it executable, and allowing it to be run as root.

# curl -q -O "" && mv wp-cli.phar /usr/sbin/ && chmod +x /usr/sbin/wp-cli.phar && \

if [[ -f /bin/php-cli ]]; then alias wp='/bin/php-cli /usr/sbin/wp-cli.phar --allow-root'; else alias wp='/usr/bin/php /usr/sbin/wp-cli.phar --allow-root'; fi

That’s it!

Running Commands

Let’s go over a few example. First we’ll want to get a list of all our WordPress instances.

Get List of WordPress Instances

# plesk ext wp-toolkit --list

You should see an output similar to this

  ID  Main Domain ID  Installation Path  Owner ID  Alive  Quarantined  Hidden                       Website URL          Name  Version
   1               1          /httpdocs         1   true        false   false  Pink Unicorn    5.3.1
   2		   2          /httpdocs/dev     2   true        false   false  Blue Unicorn    5.3.1

Wonderful! notice the ID. We’ll be using the ID number, and pass it to the commands, in order to define which site to act upon. Let’s say for example, we want to clear the cache on the site. We can run the following commans, shich doesn’t utilize the WP-CLI utility.

Clear WordPress Cache

# plesk ext wp-toolkit --clear-cache -instance-id 2

Next, we’ll use the WordPress CLI to list the plugins on the

List Plugins with WP-CLI

# plesk ext wp-toolkit --wp-cli -instance-id 2 -- plugin list

Finally, one of my favorie things to do with the WordPress CLI is searching and replacing. For example, when changing the website’s domain name. Let’s first start with a dry run. In this example we’re changing our 2nd instances domain name from to

Search and replace with WP-CLI

# plesk ext wp-toolkit --wp-cli -instance-id 2 -- search-replace --dry-run

This will output a list of all the tables in your site’s database, and how many instances of the string are goinng to be replaced, including a total. If you like what you see, run the same command without the –dry-run flag.

# plesk ext wp-toolkit --wp-cli -instance-id 2 -- search-replace

That’s it! We’ve gone over installing the WP-Toolkit Plesk Extension, and the WordPress CLI. Adding this to your WordPress and Plesk workflow should help simplify your life. I hope you enjoy. IF you want to learn more about what you can do with these tools. I’d suggest reading the official documentation.

If you are intested in other WordPress related articles, check them out.

I hope you found this helpful. You can find me at

More Great Articles

About The Author

Scroll to Top