facebook youtube pinterest twitter reddit whatsapp instagram

Installing WP-CLI In a GNU/Linux Server

WP-CLI is a command-line interface for WordPress. It can also be used with ClassicPress, as they are no differences in their usage, maybe just minimal if you are updating or downloading new ClassicPress instances.

The benefit of using WP-CLI is that:

  • It makes your life easier with the management of WorpPress or ClassicPress
  • You can regenerate thousand of thumbnails in less time
  • You can backup and or restore database file
  • Manage multiple WP website at once, say you want to install a plugin for multiple website
  • My favourite feature of wp-cli is using search and replace, e.g replacing local devlopment URL with a live one
  • Automate repetitive manual tasks with Cron
  • and lots more

Let's get started with the installation. First log into your server, and download the WP-CLI phar file using curl or wget:

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

or for wget

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

Now verify wp-cli is running using: php wp-cli.phar --info

To use WP-CLI from the command line by typing wp, make the file executable and move it to somewhere in your PATH. E.g:

chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp

This path can also be in your $HOME/bin if you have one created already.

Now run wp --infoto confirm everything is in place, you'll see something as below:

user@server:~$ wp --info
OS:     GNU/Linux 4.15.0-111-generic #112-Ubuntu SMP Thu Jul 9 20:32:34 UTC 2020 x86_64
Shell:  /bin/bash
PHP binary:     /usr/bin/php7.2
PHP version:    7.2.24-0ubuntu0.18.04.6
php.ini used:   /etc/php/7.2/cli/php.ini
WP-CLI root dir:        phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:      phar://wp-cli.phar/vendor
WP_CLI phar path:       /home/username
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.4.0
user@server:~$

To Update wp-cli, you simply run wp cli update

In feature guide, we would cover how to use wp-cli with a ClassicPress or WordPress websites, and even go into automating things with bash.

Related Post(s)

  • Setting Up Send-Only Mail Server From Scratch (With Haraka)

    In this guide, I would walk you through the steps of setting up an email server that can be used as a send-only mail server, we would not be dealing with receiving mails, we only care about sending em

  • Send Mail with Attachment Using Mutt in GNU/Linux

    Mutt is a powerful text-based mail client for Unix/Linux operating systems. It features color support, message threading, MIME support...

  • Installing and Running Rclone Mount As a Windows Service

    I previously wrote a guide on how to mount and unmount rclone in Linux, in this guide, I’ll walk you through on how to do the same on a windows system. Step 1: Download Rclone First, go to rclone d

  • Mounting and Unmounting Cloud Storage With (Rclone) in GNU/Linux

    Ever wondered if you could mount your preferred cloud storage as a virtual drive on your system? Thanks to Rclone, you can mount and access different kinds of cloud storage from a file manager, I'll

  • Access A Web Page In GNU/Linux Using (Links) [Web Browser in Text Mode]

    Links is a text-mode World Wide Web (WWW) browses that can be used to view a web page either via a local (file://) or remote ((http:// or ftp://) URLs. To get started with Links, install it using the

  • Synchronize File With Cloud Storage Using [Rclone] In (GNU/Linux)

    Rclone is an open-source command-line program to sync files and directories to and from different cloud storage providers. It preserves timestamps, and if you are transferring from local to cloud, it