In this tutorial, we will show you how to install WP-CLI on Ubuntu 22.04 LTS. For those of you who didn’t know, WP-CLI is a command-line interface for WordPress, a popular content management system (CMS) used to build and manage websites. WP-CLI provides a set of commands that simplify tasks such as managing plugins, updating themes, and managing users.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘
sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the WP-CLI command-line interface for WordPress on Ubuntu 22.04 (Jammy Jellyfish). You can follow the same instructions for Ubuntu 22.04 and any other Debian-based distribution like Linux Mint, Elementary OS, Pop!_OS, and more as well.
- A server running one of the following operating systems: Ubuntu 22.04, 20.04, and any other Debian-based distribution like Linux Mint.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for WP-CLI.
- SSH access to the server (or just open Terminal if you’re on a desktop).
non-root sudo useror access to the
root user. We recommend acting as a
non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.
Install WP-CLI on Ubuntu 22.04 LTS Jammy Jellyfish
Step 1. First, make sure that all your system packages are up-to-date by running the following
apt commands in the terminal.
sudo apt update sudo apt upgrade sudo apt install wget apt-transport-https gnupg2 software-properties-common
Step 2. Installing WP-CLI on Ubuntu 22.04.
- Method 1. Installing WP-CLI using Package Manager Ubuntu √
By default, WP-CLI is available on Ubuntu 22.04 base repository. Now run the following command below to install the latest version of the WP-CLI to your Ubuntu system:
sudo apt install wp-cli
- Method 2. Installing WP-CLI from the Source Code √
Next, make the WP-CLI package executable, and run the following command:
chmod +x wp-cli.phar
Move it to somewhere in your PATH. For example:
sudo mv wp-cli.phar /usr/local/bin/wp
To verify the installation, run the following command:
OS: Linux 22.214.171.124-microsoft-standard-WSL2 #1 SMP Wed Dec 16 11:20:35 UTC 2021 x86_64 Shell: /usr/bin/zsh PHP binary: /usr/bin/php8.1 PHP version: 8.1.0 php.ini used: /etc/php/8.1/cli/php.ini MySQL binary: /usr/bin/mysql MySQL version: mysql Ver 8.0.27-0ubuntu0.22.04.1 for Linux on x86_64 ((Ubuntu)) SQL modes: WP-CLI root dir: /home/wp-cli/ WP-CLI vendor dir: /home/wp-cli/vendor WP_CLI phar path: WP-CLI packages dir: /home/wp-cli/.wp-cli/packages/ WP-CLI global config: WP-CLI project config: /home/wp-cli/wp-cli.yml WP-CLI version: 2.7.1
Step 3. Updating WP-CLI.
If there is a core update available, you can update the WordPress install using the following command below:
wp core update
Step 4. WP-CLI Commands Examples.
Here’s a table that summarizes some of the WP-CLI commands with examples:
Congratulations! You have successfully installed WP-CLI. Thanks for using this tutorial for installing the WP-CLI command-line interface for WordPress on Ubuntu 22.04 LTS Jammy Jellyfish system. For additional help or useful information, we recommend you check the official WP-CLI website.