Install wp-cli (command line) for WordPress

To install WP-CLI for WordPress, you can follow these steps. WP-CLI is a command-line interface for managing WordPress installations, and it can be very useful for various tasks.

Prerequisites:

  1. Command Line Interface: Ensure you have access to a command line interface on your server or local machine.
  2. WordPress Installation: WP-CLI requires a working WordPress installation. Make sure WordPress is set up and running.

Installation Steps:

  1. Download the Phar Archive: Use the following command to download the WP-CLI Phar archive:
   curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

Alternatively, you can use wget:

   wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
  1. Make it Executable: Make the downloaded Phar archive executable:
   chmod +x wp-cli.phar
  1. Move to a Directory in Your $PATH: Move the wp-cli.phar file to a directory that is in your system’s $PATH. This allows you to execute it from anywhere.
   sudo mv wp-cli.phar /usr/local/bin/wp

If you encounter permission issues, you may need to use sudo or adjust file permissions accordingly.

  1. Verify Installation: Check if WP-CLI is installed correctly by running:
   wp --info

This command should display information about WP-CLI, including the version number.

Usage:

Now that WP-CLI is installed, you can use it to manage your WordPress installations. Here are a few examples:

  • Check WordPress version:
  wp core version
  • Update WordPress:
  wp core update
  • Install a Plugin:
  wp plugin install <plugin-name>
  • Update Plugins:
  wp plugin update --all

These are just a few examples. WP-CLI provides a wide range of commands to manage various aspects of your WordPress site. Refer to the official documentation for more details and commands.

Leave a comment

Your email address will not be published. Required fields are marked *