How to install WP-Cli on your Linux server

WP-CLI is a command line tool to manage your WordPress installation.
To install it on your Linux server you require SSH access for the server.

Note: To install WP-CLI you require PHP version 5.3.2 and later and WordPress version 3.5.2 and above

Step 1 : Download the ‘wp-phar.phar’ File in your ‘opt’ folder.

cd /opt
curl -O

Step 2 : Check if the file is downloaded properly

php wp-cli.phar --info

Step 3 : Rename the file to something easier to type like ‘wp’. So that you don’t have to type ‘wp-cli.phar’ every time you wish to manage your installation with WP-CLI. Before that make the file executable by changing it’s permissions.

chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp

Step 4 : Now check if the WP-CLI installation was successful or not. Move to the WordPress installation folder and type the following command.

wp core version

If you see an error message saying you are running this under root user, then add ‘–allow-root’ to the wp-cli command

wp core version --allow-root