How to use wp-cli with Plesk hosting

plesk-wordpress-cli

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 or errors about the PHP version being too old (this is likely), replace the php command with /opt/plesk/php/8.1/bin/php or swap out the ‘8.1’ with other versions of PHP like 7.4, 8.0, or 8.2. If none of those commands work it’s because your web host either does not have that version of PHP installed in Plesk or they haven’t added that version of PHP 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

Posted in , , ,

Jordan Schelew

Jordan has been working with computers, security, and network systems since the 90s and is a managing partner at Websavers Inc. As a founder of the company, he's been in the web tech space for over 15 years.
WS-Logo-only-image-large

About Websavers

Websavers provides web services like Canadian WordPress Hosting and VPS Hosting to customers all over the globe, from hometown Halifax, CA to Auckland, NZ.

If this article helped you, our web services surely will as well! We might just be the perfect fit for you.

Leave a Comment