That's the shortest way I know to install the WordPress shell extension WP-CLI:

curl https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar > /usr/local/bin/wp && chmod +x /usr/local/bin/wp

Is there an even shorter way?

Note: I use Ubuntu 16.04.

1 Answer 1


Downloading the Phar file is the recommended installation method for most users. As you showed, it's basically just one line. It can't really get shorter than that. And the steps make sense: download the file, make it executable and move it to the right location.

There are alternative ways to install WP-CLI though. For example, if you're using Composer, and have something like ~/.composer/vendor/bin in your PATH (or C:\Users\you\AppData\Roaming\Composer\vendor\bin on Windows), you can just run:

composer global require wp-cli/wp-cli

To update everything globally, run composer global update.

Alternatively, on Debian or Ubuntu you can just download and open one of the .deb packages: https://github.com/wp-cli/builds/tree/gh-pages/deb

On macOS you can install WP-CLI via Homebrew: brew install homebrew/php/wp-cli

  • Thx. It's enough to do sudo apt-get install composer -y Then, composer global require wp-cli/wp-cli and use WP-CLI regularly right away? Commented Feb 4, 2018 at 12:59
  • Yes, given that the PATH is set correctly (as I mentioned above). You can automatically set the PATH using something like echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bashrc. You only need to run this a single time. This way, your OS will search in the vendor directory when you run wp.
    – swissspidy
    Commented Feb 4, 2018 at 13:03
  • swisspidy, you have my word that I won't make a habit of this request but please review this session. You might have something to contribute to me and others: unix.stackexchange.com/questions/422719/… Commented Feb 8, 2018 at 11:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.