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.


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? – user9303970 Feb 4 '18 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 Feb 4 '18 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/… – user9303970 Feb 8 '18 at 11:10

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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