How to install WP-CLI (WordPress CLI)?

You can install WordPress CLI using SSH. It can be installed without root access. If you do not have SSH access, contact support to have it enabled for your account.


How to install WP-CLI:


Execute the following commands, one line at a time, to install WP-CLI. You will need to install it only once for the lifetime of your hosting account.

  1. Log in to SSH

  2. Download WP-CLI:

    cd ~
    curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

  3. Provide execute permissions:

    chmod +x wp-cli.phar

  4. Create an alias to make it easier to use:

    alias wp='~/wp-cli.phar'
    echo "alias wp='~/wp-cli.phar'" >> ~/.bashrc

WP-CLI is now installed on your hosting account.


How to run WP-CLI:


  1. Log in to SSH

  2. Go to the installation directory of your website.

    The default directory is public_html:

    cd ~/public_html

    The default directory for an addon domain is the domain name (e.g. example.com):

    cd ~/example.com

    You can view the installation directory from cPanel > Domains

  3. Execute a command, eg. view the configuration details:

    wp config list

  4. Execute other commands in a similar fashion.

    Make sure to change your working directory to the WordPress installation directory before executing any command.


How to run WP-CLI from the home directory:


Specify which WordPress site to control with the "--path" option:

wp config list --path=/home/username/public_html

Make sure to replace <username> with your actual username for the cPanel account.


Helpful Guides:


WordPress CLI handbook has many useful guides on how to use WP-CLI:

https://make.wordpress.org/cli/handbook/how-to/

 

  • 270 Users Found This Useful
Was this answer helpful?

Related Articles

How to change WordPress admin password?

The admin password of WordPress can be changed in multiple ways without knowing the password....

How to automatically update WordPress using Softaculous?

You can automatically update WordPress using Softaculous. By default, Softaculous updates WP core...

How to clone or stage a WordPress website using Softaculous?

  A staging site or clone allows you to test website settings, plugins, and themes before...

How to clone or stage a WordPress website using WP Toolkit?

  WP Toolkit allows you to clone your existing website. You can use the cloned site as a staging...

How to install LiteSpeed Cache for WordPress?

We automatically install and enable the LiteSpeed Cache for WordPress Plugin (LSCWP) on your...