To install WP-CLI on TEMOK's Linux Shared Hosting, please follow these instructions;
Install the WP-CLI .phar file:
Connect to your hosting account via SSH. Once logged in, make sure you are in the home directory of your hosting account. You can ensure this by using the command pwd to print the working directory. It should show you as being in /home/username, where username is your primary username for cPanel.
Use the curl command to obtain the wp-cli.phar file which we will use as the executable for wp-cli;
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
Edit the permissions of the wp-cli.phar file to be executable;
chmod +x wp-cli.phar
You can then check to see if WP-CLI functions by using php to run the executable .phar file. The command below demonstrates how to do this.
php wp-cli.phar --info
This should load up information about the php-cli executable, as well as the WP-CLI utility itself.
Setting the bash alias for WP-CLI:
So technically, you could use WP-CLI as-is. You would simply need to type php wp-cli.phar before any command to initialize WP-CLI. A great time saving feature of command line interfaces is using tab completion to quickly type in commands. We have ways to change this using a bash alias. This is done by editing your .bashrc file, which exists in the home directory of your hosting account. The alias we need to add to this .bashrc file is:
alias wp='~/wp-cli.phar'
This tells bash that the command 'wp' will call to the wp-cli.phar executable in your home directory. Adding the required alias can be done through this simple command, which simply uses echo to output the required statement, then uses >> to append it to the file.
echo "alias wp='~/wp-cli.phar'" >> .bashrc
Then, use the source command to update how bash initializes.
source .bashrc
Note: If you have made previous edits to your .bashrc file to establish another alias or install another command-line utility such as Drush, then you may instead want to edit your .bashrc file manually using a text editor such as Notepad++ or vim. However, as long as you are following the standard format and having bash aliases live at the bottom of the .bashrc file, the previous command should still work just fine.
Ensure that wp-cli works (test example):
Now that you have set up the executable and alias, that should be all you need to use WP-CLI to manage your WordPress site.
To ensure wp-cli is working, first navigate to your WordPress install directory - then use the following command:
wp plugin list
You should see a list of all the plugins that are currently installed, thus meaning that wp-cli is working as it should.