WP-CLI is a command line interface for managing your WordPress installation. WP-CLI provides a set of command line tools for updating WordPress core files, installing / removing themes or plugins, enabling / disabling plugins, and more. By using WP-CLI, you can keep your WordPress site up to date and keep your Linux safe and free from malicious files.
Today we are going to show you how to install and use WP-CLI on a server. You can use this tutorial if you have CentOS or Ubuntu with PHP 5.3.2 or later. Also, this guide can be used if you are using WordPress 3.5.2 or later for your site.
The first thing you need to do is log into the VPS using SSH. Then go to the “/ opt” directory and download the ‘wp-cli.phar’ file. You can also download the file using wget or curl. In this tutorial, 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 the files are working 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. Alternatively, you can rename the file to something simpler, so you don’t have to type ‘wp-cli.phar “every time you want to manage your WordPress installation.
chmod +x wp-cli.phar sudo mv wp-cli.phar /usr/local/bin/wp
Once you complete these two commands, you are ready to use WP-CLI. First, go to the directory where your WordPress is installed. For example, if your WordPress is installed in the ‘/ var / www / html / wordpress /’ folder, you can enter:
To check the version of your WordPress installation, you can run the following command:
wp core version
You will end up with something like this:
[[email protected]] wp core version 4.6.1
This means your WordPress version is 4.6.1, which is the latest version of WordPress at the time of this writing. So if you try to update your kernel version using the command
wp core update
you will get the following output:
[[email protected]] wp core update Success: WordPress is up to date.
To update all your themes and plugins, you can run the commands written below:
wp theme update --all wp plugin update --all
Besides, 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 get a list of installed plugins, enabled and disabled, run the following command:
wp plugin list
The same goes for your WordPress themes.
You can find more details on how to use WP-CLI on your Linux if you run the following command:
or, if you visit the official website at: