WordPress is incredibly straightforward to use with their intuitive graphical interface yet it’s not ideal relating to server administrators and hosting providers who manage scores of sites. WP-CLI (WordPress Command Line Interface) is undoubtedly a powerful tool the fact that can control every facet of WordPress from the command line.
When youre tasked with updating or installing a plugin, handling multiple WordPress sites through the command line and also scripting is more helpful. In this article, we’ll show you how in order to install WP-CLI and feature some of its nearly all useful features, including just how to install, update, as well as manage WordPress core, plugins, and themes on typically the command line.
How to Install WP-CLI
WP-CLI is a self-contained PHP app that can easily be installed both by just server administrators and normal cPanel users.
- Hardware administrators can make WP-CLI available to all for the server’s users.
- cPanel users can certainly install it in their own home directory or a good WordPress site’s directory to help control their sites.
To install and implement WP-CLI, you will desire access to your server’s command line. Administrators by using root access can diary in with SSH. cPanel users can log in with SSH if it could be available or cPanel’s inherent Terminal .

First, we desire to download WP-CLI to help the server with:
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

Before we can easily run it, we will want to provide execute accord with:
chmod +x wp-cli. phar
An individual can learn more with regards to chmod and file accord in How to Allocate Permissions to Files and even Folders in cPanel.
Setting Up WP-CLI seeing that the Root User
To allow every customer to run WP-CLI, many of us have to move it to a directory for the system’s PATH.
mv wp-cli. phar /usr/local/bin/wp
This:
- Transfers the file to “/usr/local/bin. ”
- Renames it to “wp” to have convenience, although you can certainly also choose another significant filename.
All users should be able to be able to run WP-CLI from since “wp. ”
Method Up WP-CLI as a new cPanel User
cPanel users without root entry can’t move files right into a directory in PATHWAY, but they can run it from their property folder or in a fabulous WordPress site’s directory.
To be able to run it from your own home directory, you can tell WP-CLI which Live journal site to control by using the “–path” option. With regard to example:
. /wp-cli. phar config list --path=/home/user/public_html/
If you move WP-CLI into the WordPress site’s directory, you don’t contain to supply a spot with “–path, ” nonetheless you will need in order to specify the directory the fact that contains the executable, employing “. /“ for your current directory.
/home/user/public_html/wp-cli. phar config list
To make it less difficult to use, you may create an alias, an important command-line shortcut:
mote wp='~/wp-cli. phar’
Often the shell will replace “wp” with “~/wp-cli. phar”, affording you to enter “wp” rather than the total path to the exe.
You can make the alias permanent with:
echo "alias wp='~/wp-cli. phar'" > >. bashrc
We’re adding the autrement command to your account’s. bashrc configuration file hence that it runs anytime you log in.
How WP-CLI Commands Get the job done
WP-CLI commands seem to be composed of a major command followed by subcommands for controlling particular facets of a WordPress online site.
For example:
wp help
The following “help” is a request, which has subcommands like as:
wp help core
This posters help information for “core” management features. The application has an excellent built-in help and documentation process. If you’re unsure which inturn commands you can perform or what they accomplish, help should be your current first recourse.

4 Incredibly Useful WP-CLI Commands
There happen to be over 40 commands and hundreds of subcommands. A person can read the full list in the records, but we’d like for you to highlight a few from the most useful.
- Reading and Writing Config Files
- Transforming WordPress User Passwords
- Installing WordPress heart, themes, and plugins
- Back-up and Optimize the WordPress Database
Reading and Producing WordPress’s Configuration
This config command can read and write WordPress’s settings, which is stored around the wp-config. php computer file.
To see the construction variables in a site’s wp-config. php file:
wp config list

To edit man or women configuration variables such because the database name:
wp config set DB_NAME new_name
To produce a new wp-config. php file with pre-configured areas:
wp config develop --dbname=user2_wp --dbuser=user2_wp --dbpass=new_password
Changing WordPress End user Passwords
In this recent article, Fixing Blogger Login Errors With cPanel, we explored how for you to change user passwords by means of editing the database. Here’s a faster way to help replace lost and forgotten WordPress passwords.
wp user update USERNAME --user_pass="new_password"
Although this procedure is faster, it is not as secure as the user’s plaintext security password is stored in the shell history. You can easily delete the shell background entries by using the particular up arrow to pick the command and demanding Ctrl-U to delete this.
Installing WordPress Center, Themes, and Plugins
One of the many useful aspects of preventing WordPress from the get line is the power to install everything from a plugin to a good full WordPress site.
Let’s start with a fabulous plugin:
wp wordpress plugin install hello-dolly --activate
To install without triggering, omit the “–activate” selection. To find the perfect name for a wordpress plugin, open its page for the WordPress plugin brochure and copy the WEB SITE slug. In the example of this, we used the Hey Dolly plugin and ripped the URL slug through its web page: https://wordpress.org/plugins/ hello-dolly hcg diet plan .
To install a topic:
wp theme mount twentytwenty --activate
You can also “uninstall, ” “delete, ” and “update” plugins and themes. The particular update feature is primarily useful on sites through many plugins:
To up grade all of a site’s plugins at the same exact time:
wp wordpress plugin update --all
Finally, to install a fresh WordPress site in minutes:
wp core mount --url=example. com --title="A New Site" --admin_user=frank --admin_password=astrongpassword --admin_email=frank@example. com
Running this particular on the command sections stores the plaintext administrative password in the shell history, but you can easily delete it as claimed in the previous section.
Back-Up and Improve The WordPress Database
As we explained throughout How to Back Up and Restore MySQL® Directories in cPanel, it’s straightforward to dump your site’s MySQL database in typically the cPanel interface. However, in the case you prefer to back again up from the incurable, use:
wp die bahn export --add-drop-table
This “–add-drop-table” option ensures that data is correctly substituted when restoring the back-up. E xport creates an SQL file with a filename based on the lover and database name. For you to specify a different filename, add it to typically the end of the charge:
wp db export --add-drop-table database-backup. sql
To restore the databases, import the SQL document with:
wp db import database-backup. sql
Importing is a dangerous action. It will irretrievably delete any data that was added to your database after the copy was made.
Finally, anyone can optimize or damaged dash the database. Optimizing reorganizes the way data is definitely stored to speed up reading and writing:
wp db optimize
Repair attempts to solve damaged database tables. The idea is often worth seeking when you suspect databases corruption or in an important White Screen of Demise situation where the Squidoo interface is not performing.
wp db refurbishing
Fast in addition to Efficient WordPress Multisite Management with WP-CLI
WP-CLI is an essential product for anyone who website hosts and manages large volumes of WordPress sites. It can substantially reduce your time and effort required to carry out ordinary maintenance tasks.
In this kind of article, we focused regarding running commands manually, still all the commands reviewed and many more could be used in scripts to automate complex workflows. WP-CLI can also end up being combined with cron to help schedule WordPress management jobs. We explained how to be able to automate web hosting jobs with cron in Precisely how to Configure a Cron Job.
If using the exact WP-CLI still seems a fabulous bit daunting, cPanel boasts added the most chosen WP-CLI commands to Blogger Toolkit for cPanel for Version 92. Creating a site, controlling plugins and themes, in addition to more, are the majority of just a click apart. Discover all the features of WordPress Tool set.
As always, if an individual have any feedback or perhaps comments, please let people know. We are the following to help in the exact best ways we can certainly. You’ll find us regarding Discord, the cPanel meeting places, and Reddit.
WP CLI: Install and Manage WordPress® on the Command Line