2.13.1.2.4. Installing WP-CLI

WP-CLI Is the official console utility for working with a WordPress site.

  1. Connect to hosting via SSH.
  2. Download the phar archive using curl:
    curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
  3. Verify that the file is working properly by running the command:
    php wp-cli.phar --info

    As a result, something like the following should be displayed:

    OS:     Linux
    Shell:  /bin/bash
    PHP binary:     /usr/local/php56/bin/php
    PHP version:    5.6.40
    php.ini used:
    WP-CLI root dir:        phar://wp-cli.phar/vendor/wp-cli/wp-cli
    WP-CLI vendor dir:      phar://wp-cli.phar/vendor
    WP_CLI phar path:       /home/example
    WP-CLI packages dir:
    WP-CLI global config:
    WP-CLI project config:
    WP-CLI version: 2.1.0
  4. Set the file to execute permissions by running the command:
    chmod +x wp-cli.phar
  5. For convenience, create an alias:
    Run the commands in turn:
    echo "alias wp='php ~/wp-cli.phar'" >> ~/.bashrc
    source ~/.bashrc
    Add an alias through the section "Linux configuration":
    Alias Team
    wp php ~/wp-cli.phar
  6. Check if the alias works by running the command:
    wp --info

    The result should be the same as in paragraph 3.

To run the utility in the console, use:

wp <required arguments>
Content