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 send an email from WordPress?

You can easily send email from WordPress using SMTP. You need to create an email account and use...

How to change WordPress admin password?

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

How to import or remove or uninstall WordPress in Softaculous?

  Softaculous allows easier management of websites. You can install, update, backup, clone,...

How to automatically update WordPress using Softaculous?

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

How to disable automatic WordPress optimization?

  We automatically LiteSpeed Cache and optimize all WordPress websites on your hosting account....