WP-CLI is the official command line tool for interacting with and managing your WordPress sites. WordPress Command Line Interface (WP-CLI)  is a suite of commands with which you can quickly perform plugin updates and many WordPress management tasks from the command line.

 

Using WP-CLI to install WordPress

To install WordPress using WP-CLI we recommend that you follow the instructions below. For this, you need root access on the VPS or Dedicated server.

- Log in to the server as root user

- Download wp-cli.phar using either

wget: https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar 

or

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

Note! If you choose to use wget and you get an error regarding the SSL certificate between the domains www.github.com and raw.githubusercontent.com you can "skip" the certificate check to download the file with:

wget –no-check-certificate https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

Run the following command to test WP-CLI directly with PHP:

php wp-cli.phar –info

An output similar to the following will be returned:

PHP binary:  /opt/cpanel/ea-php70/root/usr/bin/php PHP version:  7.0.26 php.ini used: /opt/cpanel/ea-php70/root/etc/php.ini WP-CLI root dir:  phar://wp-cli.phar WP-CLI packages dir:   WP-CLI global config:  WP-CLI project config:   WP-CLI version: 0.24.1

Make the WP-CLI file executable and move it to your path:

chmod +x wp-cli.phar

mv wp-cli.phar /usr/local/bin/wp

Use wp at the command line to access WP-CLI:

wp –info

 

Setting up Bash Tab-to-Complete for WP-CLI

An excellent time-saving feature for the command line interface is TAB completion, for quick command entry. You can add the ability to use TAB completion for WP-CLI by setting this in your local ~/.bash_profile file.

- Log in to the server via SSH as the user who will use WP-CLI

- Download the WP-CLI tab completion file to your server
 

curl -O https://raw.githubusercontent.com/wp-cli/wp-cli/master/utils/wp-completion.bash

or

wget https://raw.githubusercontent.com/wp-cli/wp-cli/master/utils/wp-completion.bash

Note! If you choose to use wget and you get an error regarding the SSL certificate between the domains www.github.com and raw.githubusercontent.com you can "skip" the certificate check to download the file with:

wget –no-check-certificate https://raw.githubusercontent.com/wp-cli/wp-cli/master/utils/wp-completion.bash

- Move the WP-CLI tab completion file to your home directory:

mv wp-completion.bash ~/

Edit the ~/.bash_profile file to include the WP-CLI tab completion file:

vi ~/.bash_profile

- Add the following line to the bottom of your  ~/.bash_profile file:

source ~/wp-completion.bash

Save the file.

- Back to the command line, find the source of your ~/.bash_profile file by running the command:

source ~/.bash_profile

- Now type wp in the command line and double click on the Tab to see all the executions in the tab that you have just configured:

[email protected] [/home/examplu/public_html]# wp
cache  comment  eval  help  menu  plugin  role  shell  super-admin  transient
cap  core  eval-file  import  network  post  scaffold  sidebar  term  user  cli
db  export  media  option  rewrite  search-replace  site  theme  widget

 

For assistance in applying the above instructions on HostX servers please contact us. HostX offers the fastest WordPress hosting and can help you solve your problems.

Was this answer helpful? 0 Users Found This Useful (0 Votes)