5. Install WP-CLI
Installation
Downloading the Phar file is our recommended installation method for most users. Should you need, see also our documentation on alternative installation methods (Composer, Homebrew, Docker).
Before installing WP-CLI, please make sure your environment meets the minimum requirements:
UNIX-like environment (OS X, Linux, FreeBSD, Cygwin); limited support in Windows environment
PHP 5.6 or later
WordPress 3.7 or later. Versions older than the latest WordPress release may have degraded functionality
Once you’ve verified requirements, download the wp-cli.phar file using wget or curl:
Next, check the Phar file to verify that it’s working:
To use WP-CLI from the command line by typing wp, make the file executable and move it to somewhere in your PATH. For example:
If WP-CLI was installed successfully, you should see something like this when you run wp --info:
Updating
You can update WP-CLI with wp cli update (doc), or by repeating the installation steps.
If WP-CLI is owned by root or another system user, you’ll need to run sudo wp cli update.
Want to live life on the edge? Run wp cli update --nightly to use the latest nightly build of WP-CLI. The nightly build is more or less stable enough for you to use in your development environment, and always includes the latest and greatest WP-CLI features.
Tab completions
WP-CLI also comes with a tab completion script for Bash and ZSH. Just download wp-completion.bash and source it from ~/.bash_profile:
Don’t forget to run source ~/.bash_profile afterwards.
If using zsh for your shell, you may need to load and start bashcompinit before sourcing. Put the following in your .zshrc:
Allow root instance
To allow cli usage with root permission simply add this enviroment variable: