Using WP-CLI to Manage WordPress on Ubuntu

Updated on September 23, 2015
Using WP-CLI to Manage WordPress on Ubuntu header image

WP-CLI is a tool that allows you to manage WordPress installations on your server from the command line. It can be very handy for efficient management of multiple WordPress installations. This guide assumes that you have already installed WordPress on a LAMP stack.

WP-CLI comes pre-installed on the Vultr One-Click WordPress app.

Step 1: Installing WP-CLI

Before we can actually use WP-CLI to manage WordPress, we need to install it:

cd ~
curl -k -L https://raw.github.com/wp-cli/builds/gh-pages/phar/wp-cli.phar > wp-cli.phar

Test it:

php wp-cli.phar --info

This will display PHP information.

Step 2: Modifying ~/.bashrc

In order for the wp command to work, we need to alter our ~/.bashrc file. Open it, and add the following line:

alias wp="php /home/USERNAME/wp-cli.phar"

Now reload the file:

source ~/.bashrc

Step 3: Using WP-CLI

In order to use WP-CLI, navigate to the folder that contains your WordPress installation. You can now use WP-CLI commands in that folder. For example, try updating your WordPress installation with the following command:

wp core update

For a full list of WP-CLI commands, see the documentation on the official site.