Setting up WP-CLI is super easy and can be done in just a few steps.
Installation
First download WP-CLI using curl
or wget
.
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
Next check if it worked.
php wp-cli.phar --info
To make things easier, make the wp-cli.phar
file an executable.
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
sudo: command not found
If you don’t have sudo powers there are a number of things you can do:
Easy Way
You can use the relative path to the wp-cli.phar
file.
~/wp-cli.phar
Best Way
A better solution would be to create an alias to run the same command as above with less keystrokes.
Open up your .bashrc file and add this line to the bottom
# User specific aliases and functions
alias wp="~/wp-cli.phar"
Re-source your .bash_profile and run wp --info
.
source .bash_profile
wp --info