Vijayan
Vijayan Thanks for stopping by guys! I'm Vijayan and Techpulse is my beloved brainchild. Currently working as a PHP developer in a digital marketing start-up, I'm overly passionate about not just learning new things but also putting those into practice. I swear by a quote I once came across... 'What separates successful people from unsuccessful people is the former's ability to execute'. Feel free to reach out to me if you have any questions, suggestions or feedback. Hoping to see more of you here!

How to Install WP-CLI on a linux


How to Install WP-CLI on a linux

WP-CLI will be particularly useful if you are a WordPress developer, System Administrator or run a business built on WordPress. WP-CLI is an awesome command line tool for WordPress. It has a lot of commands that can help us installing plugins/themes, add posts, updating WordPress Core, taking backups, querying databases, import/export data quickly and easily. This command line tool will greatly help you do more in less time.

Download WP-CLI

First Connect your server through SSH. wp-cli.org recommended to install WP-CLI is by downloading the Phar file. The latest version WP-CLI installation file is available here. You can download by using wget or curl. For Example:

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

wp-cli-1

Check if it works

Enter the following command to check if it works or not.

1
php wp-cli.phar --info

wp-cli-2

Creating executable files

Enter the following command to make it executable.

1
chmod +x wp-cli.phar

wp-cli-3

Move WP-CLI.PHAR File

We can move wp-cli.phar file to /usr/local/bin and rename it to wp. This will help us use the WP-CLI commands by just typing ‘wp’ at the start of the commands. Type wp –info to check the status.

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

wp-cli-4

WP-CLI Update

In future, you can update wp cli by entering the following command to update.

1
sudo wp cli update

wp-cli-5

For more information about wp-cli installation click here.

wp-cli bash completion

The bash completion feature of WP-CLI allows you to see all the available commands on the fly.

Download the bash script in your home directory

1
2
cd ~/
wget https://github.com/wp-cli/wp-cli/raw/master/utils/wp-completion.bash

Edit the .bashrc file

Edit the file .bashrc so that it is loaded by the shell every time you log in. Open the file and add the following line in the editor:

1
source /home/$USER/wp-completion.bash

Run the following command to reload the bash profile

1
source ~/.bashrc

That’s it. Bash completion is now enabled. To test it, type wp theme (include the trailing space) and press Tab twice. You will see the list of available commands with wp theme again on the prompt.

comments powered by Disqus