How to use wp-cli with Plesk hosting

If you use WordPress to power your website and have a bit of technical knowledge (particularly of Linux shell), then taking advantage of the command line interface tool, wp-cli, might be of interest to you!

WP-CLI is a command line method of working with WordPress. Rather than triggering actions by logging in to the WordPress admin GUI, you do so when logged in via SSH command line. One advantage to using wp-cli is that you bypass the entire web server stack, including nginx, apache, fastcgi, and php, which can be advantageous particularly when running longer-running tasks (like imports/exports of data) since you’re no longer subjected to heavy timeout restrictions on each process.

Let’s get started:

  1. Log in to your Plesk system user account via SSH (If you have your own VPS, it’s best not to run this as root, but you can sudo to the domain’s system user account prior to running the commands)
  2. Change to your web root directory where WordPress is installed. The web root folder/dir for each domain is shown in Plesk. For your primary domain this is httpdocs.
  3. Run the following to download and run wp-cli’s info function:
wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
php wp-cli.phar --info

For any wp-cli command you see in their documentation, simply cd to your web root dir and replace ‘wp’ with ‘php wp-cli.phar’.

 If you get an error indicating that php doesn’t exist, replace the php command with /opt/plesk/php/7.3/bin/php or swap out the ‘7.3’ with other versions of PHP like 5.6, 7.1, or 7.2. If none of those commands work it’s because your web host does not have php added to the chroot. You’ll need to ask them to fix this, or consider switching to better Plesk web hosting!


Source for installing wp-cli

Jordan is a computer, security, and network systems expert and a lover of all things web and tech. Jordan consults with project management for software companies. Jordan is a founder and managing partner at Websavers Inc.

Leave a Comment