WP-CLI is the command-line interface for WordPress. The WP-CLI is a tool that enables you to interact with your WordPress site directly by using commands in a text-based interface. It’s also very comprehensive, featuring a wide variety of potential commands. Almost anything you can do on the back end of your site, you can do much faster using the WP-CLI.
In the following tutorial, you will learn how to install WP-CLI on any Linux server.
- Recommended OS: Any Linux operating system.
- Required Software: WordPress
- User account: A user account with sudo or root access.
- Recommended Packages: curl or wget
Install WP-CLI on Linux
The easiest and recommended way to install WP-CLI on your Linux server is to download the Phar file. In the following tutorial below, you will see examples from an Ubuntu 20.04 server. However, these commands will work on most Linux operating systems.
First, download the phar file using curl command with the following command:
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
Next, you should verify the file is working correctly as follows:
php wp-cli.phar --info
You will now need to make WP-CLI executable by using the following command:
chmod +x wp-cli.phar
Lastly, move the executable:
sudo mv wp-cli.phar /usr/local/bin/wp
To test if WP-CLI was installed successfully, use the following command:
Example output below:
To update WP-CLI is an easy process. It also has a stable option and nightly option for those that are more game.
To update using the standard stable build, use the following command:
wp cli update
Note, if the file is owned by root, you may need to use sudo privileges as follows:
sudo wp cli update
To install the nightly build, use the following:
wp cli update --nightly
Comments and Conclusion
In the tutorial, you have learned how to install WP-CLI on your Linux server. Overall, WP-CLI is handy, especially for running some cron from certain plugins that have WP-CLI support. It can be a handy feature and asset to have overall if you are working with WordPress.
For more information on using WP-CLI, read the quick start guide.