WP-CLI, the command-line interface that empowers developers, sysadmins, and site maintainers to manage WordPress sites quickly and efficiently. Whether you’re updating plugins, managing users, or running database operations, WP-CLI streamlines your workflow. In this blog we will learn the process of Installing WP-CLI to Manage WordPress from the Command Line
What is WP-CLI ?
WP-CLI is a command-line tool for interacting with and managing WordPress installations. Instead of clicking through the WordPress admin UI, you can do tasks like:
- Installing and updating plugins and themes
- Managing users
- Performing database migrations
- Running search-replace operations
Installation Method
The preferred method for installing WP-CLI is by downloading the Phar (PHP Archive) build. This is a self-contained executable.
Step 1: Download the Phar file
Use curl or wget to download the WP-CLI Phar:
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
Step 2: Verify the Phar works
Before installing, ensure it runs correctly:
php wp-cli.phar --info
You should see output detailing your OS, PHP version, and WP-CLI version.
Step 3: Make WP-CLI globally accessible
To use wp as a command (instead of php wp-cli.phar), make the file executable and move it to a directory in your system’s path.
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
Now, try:
wp --info
If installed successfully, you’ll see output like:
OS: Linux 4.10.0-42-generic
PHP version: 7.1.12
WP-CLI version: 1.5.0
...
Keeping WP-CLI Up to Date
WP-CLI can be easily updated using the following command:
wp cli update
You will be prompted to confirm to update with a message similar to the following:
You have version 0.21.1. Would you like to update to 0.23.1? [y/n]
Respond with “y” and you should see:
Success: Updated WP-CLI to 0.23.1
If you are already using the latest version, you will see this message:
WP-CLI is at the latest version.
Are you in need of assistance with installing WP-CLI, which is the way to manage WordPress from the command line, or are you looking for expert server management services? Contact our team today for professional support and streamlined WordPress management!