How to install and use WP-CLI on a Linux VPS
Today we are going to show you how to install and use WP-CLI on your server. You can use this guide if you have CentOS VPS or Ubuntu VPS with PHP 5.3.2 or later installed. Also, this guide applies if you are using WordPress 3.5.2 or later for your site.
First thing you need to do is to log in to your VPS via SSH. Then, navigate to your ‘/opt’ directory and download the ‘wp-cli.phar’ file. You can download the file using wget or curl. In this guide, we are using curl.
cd /opt curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
Now, you can check if the file works by running the following command:
php wp-cli.phar --info
Make the file executable and move it to the ‘/usr/local/bin/’ directory on your server. Also, you can rename the file to something more simple so you will not have to type ‘wp-cli.phar’ every time you like to manage your WordPress installation.
chmod +x wp-cli.phar sudo mv wp-cli.phar /usr/local/bin/wp
Once you execute these two commands, you are ready to use WP-CLI. First, navigate to the directory where your WordPress is installed. For example, if your WordPress is installed in the ‘/var/www/html/wordpress/’ directory, you can type:
To check the version of your WordPress installation, you can execute the following command:
wp core version
You will get something like this:
[[email protected]] wp core version 4.2
This means that your WordPress version is 4.2, which is the latest version of WordPress at the moment of writing this tutorial. Therefore, if you try to update your core version using the command
wp core update
you will get the following result:
[[email protected]] wp core update Success: WordPress is up to date.
To update all your themes and plugins, you can execute the commands written below:
wp theme update --all wp plugin update --all
Similarly, you can install/uninstall plugins and themes. For example, to install the wordfence plugin, you can use the following command:
wp plugin install wordfence
To activate the plugin, you can run the following command:
wp plugin activate wordfence
To list the installed plugins, both enabled and disabled, execute:
wp plugin list
The same applies for your WordPress themes.
More information about how to use WP-CLI on your Linux VPS you can find if you run the following command:
or, if you visit the official web site at:
Of course you don’t have to do any of this if you use one of our Linux VPS hosting services, in which case you can simply ask our expert Linux admins to install WP-CLI for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.