Search form

Install WP-CLI

The wp-cli command-line utility allows you to manage your WordPress sites without going through the WordPress dashboard, much like Drush does for Drupal.

To install Composer and wp-cli on Ubuntu 16.04:

Install Composer

(I'd recommend not doing this as root.)

user@ubuntu# cd $HOME
user@ubuntu# php -r "copy('', 'composer-setup.php');"
user@ubuntu# php -r "if (hash_file('SHA384', 'composer-setup.php') === 'aa96f26c2b67226a324c27919f1eb05f21c248b987e6195cad9690d5c1ff713d53020a02ac8c217dbf90a7eacc9d141d') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
user@ubuntu# php composer-setup.php
user@ubuntu# php -r "unlink('composer-setup.php');"

Install wp-cli

user@ubuntu# composer global require wp-cli/wp-cli

This installs wp-cli to $HOME/.config/composer/vendor/wp-cli/wp-cli/bin/wp

user@ubuntu# $HOME/.config/composer/vendor/wp-cli/wp-cli/bin/wp cli version
WP-CLI 0.25.0

To make things easier on yourself, symlink it:

user@ubuntu# sudo ln -s $HOME/.config/composer/vendor/wp-cli/wp-cli/bin/wp /usr/bin/wp
user@ubuntu# wp cli version
WP-CLI 0.25.0