Single Blog

Learn to Install and Manage WordPress Sites With WP-CLI

February 24, 2020, Written by 0 comment

The below steps can be run with root privileges on a server (VPS hosting). This feature is preinstalled with our VPS hosting accounts.

In this tutorial, you will learn to install and manage WordPress with the WP-CLI. WP-CLI offers a command line interface for WordPress. Users get 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

Firstly, using SSH connect to your Server’s console. Then you can download the file wp-cli.phar using wget or curl.

 

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

Then, check if the downloaded Phar file is working.

 

1 php wp-cli.phar –info

Then you will need to set the permission to make the Phar file executable using the below command:

 

1 chmod +x wp-cli.phar

Now, move the file wp-cli.phar to a new directory named wp under /usr/local/bin. With this, you will be able to execute the WP-CLI commands by typing ‘wp’ at the start.

 

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

Run wp –info to check if the installation was successful. If it was successful, you’ll see the output below:

Steps to Manage WordPress with WP-CLI

Let’s check some basic and useful WP-CLI commands.

WP-CLI Help System

WP-CLI offers a guide that is accessible by using “wp help“. This guide will give you a detailed info about a specific command. For example, if you want to learn in detail about config command, you can type in:

 

1 wp help config

Check the below sample output:

Steps to Manage Themes

Using the below command, list the themes present in your WordPress:

 

1 wp theme list

You will get the below output:

You can install a different theme, using the following command:

 

1 wp theme activate twentyseventeen

Steps to Manage Plugins

Similar to themes, you can also install and manage plugins using wp-cli.

Using the below command you can list the plugins that are already installed on your WP site.

 

1 wp plugins list

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

 

1 wp plugin search yoast

You will get the below output:

Use the below command to install and activate the plugin:

 

1 wp plugin install wordpress-seo –activate

Steps to Update WordPress

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

Use the below command to update the WordPress core files.

 

1 wp core update

Then, use the below command to update the database:

 

1 wp core update-db

These are just the few commands that we have discussed in this guide. You will find more commands to manage your database, posts, and multi-sites.

admin

Leave a reply

Your email address will not be published. Required fields are marked *