Knowledgebase Home / How to Install and Manage WordPress Sites With WP-CLI
// View Comments //

How to Install and Manage WordPress Sites With WP-CLI

The following steps are meant to be run with root privileges on a server (VPS hosting). This feature comes preinstalled with our shared/reseller hosting accounts.

This tutorial will help you to install and manage WordPress with the WP-CLI. WP-CLI provides a command line interface for WordPress. WP-CLI provides users the tools necessary to install and update plugins, create databases without using a web browser. 

Prerequisites

  • Unix-like environment (Linux, FreeBSD, Cygwin).
  • PHP 5.4 or later
  • WordPress 3.7 or later

Installation

Connect to your Server’s console through SSH. You can now download the file wp-cli.phar using wget or curl.

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

Next, check whether the downloaded Phar file is working.

php wp-cli.phar --info

Now, set the permission to make the Phar file executable with the following command:

chmod +x wp-cli.phar

Move the file wp-cli.phar to a new directory named wp under /usr/local/bin. This allows us to execute the WP-CLI commands by typing ‘wp’ at the start.

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

Run wp –info to check whether the installation was successful.  If the installation was successful, you’ll see the following output below,

Verifying the installation using wp --info.

Verifying the installation using wp –info.

Managing WordPress with WP-CLI

Lets go over some basic and useful WP-CLI commands.

WP-CLI Help System

WP-CLI comes with a guide which can be accessed by using “wp help“. You can get a detailed info about a specific command here. For example, if you want to know more about config command, you can type in:

wp help config

A sample output:

Man page of wp config.

Man page of wp config.

Managing Themes

To list themes present in your WordPress, you can use the following command:

wp theme list

The output will be:

Managing WordPress themes.

Managing WordPress themes.

If you want a different theme, use the following command:

wp theme activate twentyseventeen

Managing Plugins

Like themes, plugins can also be installed and managed using wp-cli.

The following command is used for listing the plugins that were already installed on your WP site. 

wp plugins list

Also you can search and install the plugins available from the command line. For example,  use the command below to search for the plugin “Yoast SEO”.

wp plugin search yoast

The output will be:

Managing WordPress plugins via the command line.

Managing WordPress plugins via the command line.

For installing and activating the plugin, you can use the below command.

wp plugin install wordpress-seo --activate

Updating WordPress

When updating WordPress from the command line, you need to update the core WordPress files and the database to complete the update process.

 Update the WordPress core files with the command shown below:

wp core update

Then, update the database using the command below:

wp core update-db

The commands we discussed on this guide are just the tip of the iceberg. There are many more commands to manage your database, posts, and multi-sites. Refer to this documentation from WordPress for more information on WP-CLI commands.

Conclusion

Congratulations! Now you know how to manage your WP installation from the command line. For more information on WP-CLI, please visit their official page.


If you have any web hosting questions please feel free to reach out to us. We're happy to help.
Shared Hosting | Reseller Hosting | Managed WordPress Hosting | Fully Managed VPS Hosting

Our Guiding Principles

  • Provide consistent, stable, and reliable web hosting services.
  • Ensure rapid ticket response and quick resolutions to issues.
  • Never saturate or over-provision servers to ensure stability and speed for our customers.
  • Use only high-quality enterprise-class hardware to ensure minimal downtime from hardware failures.
  • Provide clear pricing with no hidden fees or gotchas.
Subscribe to comment notifications
Notify of
guest
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
WP User
WP User
2 years ago

Thanks, this has been super helpful.

WP User
WP User
2 years ago
Reply to  WP User

Agreed