WP-CLI is a command-line interface for WordPress. It allows you to manage your WordPress website through the command line, which can be faster and more efficient than using the WordPress admin interface. This guide will provide you with step-by-step instructions on how to install WP-CLI on both Linux and Windows environments.
Prerequisites:
- PHP 5.4 or later
- WordPress 3.7 or later
- SSH access to your server for Linux installations
- Administrator privileges for Windows installations
Installation on Linux
- Download WP-CLI:
Open a terminal window and download the WP-CLI installation script using wget or curl. Use the following command to download the WP-CLI Phar file:
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar- Make WP-CLI Executable:
You will need to make the downloaded Phar file executable. You can do this with the following command:
chmod +x wp-cli.phar- Move WP-CLI to Bin Directory:
For easy access, you will want to move the executable to your PATH. The /usr/local/bin directory is a common location. Use the following command to move the file:
sudo mv wp-cli.phar /usr/local/bin/wp- Verify WP-CLI Installation:
Finally, check that WP-CLI has been installed correctly by displaying the version number. You can do this with the following command:
wp --infoInstallation on Windows
- Download WP-CLI:
Visit the WP-CLI’s Github page and download the latest Phar file. You can download the file directly from this URL:
https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar- Download and Install Cygwin:
Since WP-CLI is a command line tool, and Windows does not have a built-in suitable terminal, you will need to download and install Cygwin. You can download it from the official site:
https://www.cygwin.com/During installation, ensure that you install the curl, php, php-curl, php-mbstring, openssl, and openssh packages.
- Move WP-CLI to the Cygwin Directory:
Move the wp-cli.phar file to your Cygwin home directory, usually C:\cygwin64\home\Your_User.
- Make WP-CLI Executable:
Open Cygwin terminal and navigate to your home directory using cd ~. Then, make the downloaded Phar file executable with the following command:
chmod +x wp-cli.phar- Move WP-CLI to Bin Directory:
For easy access, you will want to move the executable to your PATH. The /usr/bin directory within Cygwin is a common location. Use the following command to move the file:
mv wp-cli.phar /usr/bin/wp- Verify WP-CLI Installation:
Finally, check that WP-CLI has been installed correctly by displaying the version number. You can do this with the following command:
wp --infoConclusion
Now that WP-CLI is installed, you can start using it to manage your WordPress site from the command line. If you need help getting started with WP-CLI, the official WP-CLI website provides a comprehensive guide and detailed command reference.