How To Install WP-CLI on Debian 13

Install WP-CLI on Debian 13

If you manage WordPress sites on a Linux server, clicking through the admin dashboard for every plugin update, database export, or user reset is a real time drain. WP-CLI is the official command-line interface for WordPress, and learning how to install WP-CLI on Debian 13 is one of the best productivity investments you can make as a sysadmin or developer. With a single terminal command, you can do in seconds what the WordPress dashboard takes minutes to accomplish.

Debian 13, codenamed “Trixie”, was released on August 9, 2025, and ships with PHP 8.4 by default. That makes it an excellent, modern base for running WP-CLI without compatibility headaches. This guide walks you through every step of a clean WP-CLI on Debian 13 setup, from installing dependencies to verifying the installation and running your first real WordPress commands.

Whether you are a beginner spinning up your first VPS or an intermediate sysadmin standardizing tooling across a fleet of servers, this Linux server tutorial gives you everything you need to configure WP-CLI on Debian 13 correctly the first time.

What Is WP-CLI and Why Does It Matter?

WP-CLI is a PHP-based command-line tool that loads your WordPress installation directly, reads your wp-config.php, and lets you execute any WordPress action without opening a browser. The current stable release is WP-CLI 2.12.0, maintained by the WordPress open-source community.

Here is what you can do with it in one line that would otherwise take multiple dashboard clicks:

  • Update all plugins: wp plugin update --all
  • Export the entire database: wp db export backup.sql
  • Reset an admin password: wp user update 1 --user_pass=NewPass
  • Install and configure WordPress from scratch: wp core install

On a headless Debian 13 VPS with no GUI, WP-CLI is not just convenient. It is essential.

Prerequisites

Before you begin the WP-CLI on Debian 13 setup, make sure the following conditions are met on your server.

System Requirements:

  • Debian 13 (“Trixie”) installed, either bare-metal or VPS
  • A non-root user with sudo privileges (running as root requires the --allow-root flag and is not recommended for production)
  • PHP 5.6 or higher (Debian 13 ships PHP 8.4, which exceeds this requirement)
  • WordPress 3.7 or newer installed on the server for site-level commands to work

Required Packages:

  • php-cli — runs PHP from the terminal
  • curl — downloads the WP-CLI Phar file
  • less — handles WP-CLI’s help output pager
  • ca-certificates — validates the HTTPS connection during download

Network Access:

  • The server must reach raw.githubusercontent.com to download the official Phar build

Recommended Knowledge:

  • Basic Linux terminal navigation (cd, ls, chmod)
  • Familiarity with sudo and file permissions

Step 1: Update Your Debian 13 System

The first step in any Linux server tutorial is to bring the system fully up to date. Skipping this step can cause dependency conflicts when you install php-cli in the next step.

Run the following command:

sudo apt update && sudo apt upgrade -y

What this does:

  • apt update refreshes the local package index from all configured repositories
  • apt upgrade -y installs all available updates without prompting for confirmation

If the upgrade includes a kernel update, reboot the server before continuing:

sudo reboot

After the system comes back up, reconnect via SSH and move to Step 2.

Step 2: Install PHP CLI and Required Dependencies

WP-CLI needs the PHP CLI binary to run. This is different from php-fpm, which handles web requests from Nginx or Apache. WP-CLI only uses the command-line version, so you do not need to touch your web server configuration.

Install all required packages in one command:

sudo apt install -y php-cli curl less ca-certificates

On Debian 13, the php-cli metapackage automatically resolves to php8.4-cli, since PHP 8.4 is the default version in the Trixie repositories.

Confirm PHP is available and on your PATH:

php --version

Expected output:

PHP 8.4.x (cli) (built: ...)
Copyright (c) The PHP Group

If you see this output, your environment is ready. If the command returns command not found, double-check that php-cli installed without errors by running sudo apt install php-cli again.

Why php-cli and Not php-fpm?

php-fpm (FastCGI Process Manager) runs as a background service and handles HTTP requests from your web server. WP-CLI never touches HTTP. It runs PHP scripts directly from the shell, which is exactly what php-cli is built for. Installing the wrong variant is a common beginner mistake that causes a wp: command not found error even after a successful download.

Step 3: Download the Official WP-CLI Phar File

How To Install WP-CLI on Debian 13 officially starts here. The recommended installation method from the WP-CLI project is to download the standalone Phar (PHP Archive) file. A Phar is a self-contained PHP application packaged into a single file, similar in concept to a Java JAR file. It requires no package repository and always gives you the latest release directly from the WP-CLI project.

Download it using curl:

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

Breaking down the curl flags:

  • -f — fails silently on HTTP errors (prevents saving an error page as the file)
  • -s — silent mode, suppresses progress output
  • -S — shows errors even in silent mode
  • -L — follows HTTP redirects automatically
  • -o wp-cli.phar — saves the output to a file named wp-cli.phar

After the download finishes, confirm the file exists and is not empty:

ls -lh wp-cli.phar

Expected output:

-rw-r--r-- 1 youruser youruser 6.5M Apr 10 09:45 wp-cli.phar

A file size around 5-7 MB is normal. A file that is only a few kilobytes means curl saved an error response instead of the actual Phar.

Verify the Download Integrity (Recommended)

Before you trust any binary you downloaded from the internet, verify it. Run this quick PHP check to confirm the Phar file is valid and not corrupted:

php wp-cli.phar --info

If the output shows the WP-CLI version and PHP details, the file is good. If you see a PHP parse error or garbled output, re-download the file.

Step 4: Make WP-CLI Executable

Downloaded files on Linux are not executable by default. This is intentional: it prevents accidentally running malicious files you downloaded. You need to explicitly grant execute permission.

chmod +x wp-cli.phar

Verify the permission change:

ls -lh wp-cli.phar

Expected output:

-rwxr-xr-x 1 youruser youruser 6.5M Apr 10 09:45 wp-cli.phar

The x bits on the permissions string (rwxr-xr-x) confirm the file is now executable by the owner and readable and executable by others.

If you skip this step and try to run the file, you will get:

bash: ./wp-cli.phar: Permission denied

This is one of the most common installation errors for first-time users.

Step 5: Move WP-CLI to a System-Wide PATH Location

Right now, wp-cli.phar only works from the current directory. To run wp from anywhere on the system, you need to move the file to /usr/local/bin/ and rename it to wp at the same time.

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

Why /usr/local/bin/?

On Debian systems, /usr/local/bin/ is the standard directory for locally installed programs that are not managed by APT. It is always included in the default PATH variable for all users, which means any user on the server can run wp without specifying the full path.

Confirm the binary is in place:

which wp

Expected output:

/usr/local/bin/wp

Step 6: Verify the WP-CLI Installation on Debian 13

This is the moment of truth. Run the built-in --info flag to confirm WP-CLI installed correctly and is reading the right PHP version:

wp --info

Expected output on Debian 13:

OS:             Linux 6.x.x #1 SMP x86_64
Shell:          /bin/bash
PHP binary:     /usr/bin/php8.4
PHP version:    8.4.x
php.ini used:   /etc/php/8.4/cli/php.ini
WP-CLI version: 2.12.0

Run a second confirmation to double-check the version:

wp cli version

Expected output:

WP-CLI 2.12.0

If both commands return clean output, your configure WP-CLI on Debian 13 process is complete. You now have a working, globally accessible wp command on your server.

Running WP-CLI as the Correct Server User

This section is critical for production servers and one that most tutorials skip. WordPress files on a Debian 13 LEMP or LAMP server are typically owned by www-data, the web server user. If you run WP-CLI as a different user, it can create new files with the wrong ownership, which will break your site’s ability to write uploads, update plugins, or modify themes.

Always run site-modifying commands like this:

sudo -u www-data wp plugin update --all

Before running any site command, navigate to the WordPress document root first:

cd /var/www/html/wordpress
sudo -u www-data wp core version

WP-CLI locates your site by reading wp-config.php from the current directory. If you run wp from the wrong directory, you get the error: Error: This does not seem to be a WordPress install.

You can also use the --path flag to point WP-CLI at a specific WordPress root without changing directories:

sudo -u www-data wp --path=/var/www/html/mysite plugin list

Enable WP-CLI Bash Tab Completion

WP-CLI ships with an official Bash completion script. Once set up, pressing Tab after any wp command shows you the available subcommands, which dramatically speeds up your workflow.

Download and activate it:

curl -fsSL https://raw.githubusercontent.com/wp-cli/wp-cli/v2.12.0/utils/wp-completion.bash -o ~/.wp-completion.bash
echo 'source ~/.wp-completion.bash' >> ~/.bashrc
source ~/.bashrc

Test it: type wp plugin in the terminal and press Tab twice. You will see a list of all available plugin subcommands appear inline.

This setting persists across all future login sessions because the source command is now part of your ~/.bashrc.

Essential WP-CLI Commands to Start With

Now that your WP-CLI on Debian 13 setup is complete, here are the most useful commands organized by category.

Core WordPress Management

# Check installed WordPress version
wp core version

# Update WordPress core
wp core update

# Verify core file integrity against WordPress.org checksums
wp core verify-checksums

Plugin and Theme Management

# List all plugins with their status
wp plugin list

# Update all plugins at once
wp plugin update --all

# Activate a theme
wp theme activate twentytwentyfour

Database Operations

# Export the entire database to a file
wp db export backup-$(date +%F).sql

# Run a serialization-safe search and replace
wp search-replace 'http://old-domain.com' 'https://new-domain.com'

User Management

# Create a new admin user
wp user create newadmin admin@example.com --role=administrator

# Reset an existing user's password
wp user update 1 --user_pass=NewSecurePassword123

Cache and Cron

# Flush the WordPress object cache
wp cache flush

# Run all due cron events immediately
wp cron event run --due-now

How to Update WP-CLI on Debian 13

Because WP-CLI was installed as a standalone Phar file, it does not update through apt upgrade. You need to trigger updates manually or via a cron job.

Run the built-in self-update command:

sudo wp cli update

sudo is required here because the binary lives in /usr/local/bin/, which needs root permissions to overwrite.

To check whether an update is available without applying it:

wp cli check-update

A good practice is to schedule a monthly check on production servers using cron:

sudo crontab -e

Add this line to run the self-update check on the first day of every month:

0 3 1 * * /usr/local/bin/wp cli update --yes

Troubleshooting Common WP-CLI Errors on Debian 13

Even with a clean installation, you may hit a few common issues. Here are the four most frequent ones and how to fix them.

Error 1: wp: command not found

Cause: /usr/local/bin is not in the active PATH, or the file was not moved correctly.

Fix:

# Check if the file is in place
ls -lh /usr/local/bin/wp

# Temporarily add to PATH
export PATH=$PATH:/usr/local/bin

# Make it permanent
echo 'export PATH=$PATH:/usr/local/bin' >> ~/.bashrc
source ~/.bashrc

Error 2: Error: This does not seem to be a WordPress install

Cause: WP-CLI was run from a directory that does not contain wp-config.php.

Fix: Navigate to the correct WordPress root directory first, or use the --path flag:

wp --path=/var/www/html/mywordpresssite core version

Error 3: PHP Fatal error: Allowed memory size exhausted

Cause: The PHP CLI memory limit is too low for larger WordPress operations.

Fix: Edit the PHP CLI configuration file:

sudo nano /etc/php/8.4/cli/php.ini

Find and update this line:

memory_limit = 256M

Save and close. No service restart is needed since PHP CLI reads php.ini fresh on each execution.

Error 4: Permission denied When Updating Plugins

Cause: You are running wp as a user who does not own the WordPress files.

Fix: Run the command as the web server user:

sudo -u www-data wp plugin update --all

Error 5: Warning: Could not find php-cgi

Cause: WP-CLI is looking for php-cgi for certain operations, but only php-cli is installed.

Fix: Install the CGI variant:

sudo apt install -y php8.4-cgi

Congratulations! You have successfully installed WP-CLI. Thanks for using this tutorial for installing the WP-CLI command-line interface for WordPress on Debian 13 “Trixie” system. For additional help or useful information, we recommend you check the official WP-CLI website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!
r00t is a Linux Systems Administrator and open-source advocate with over ten years of hands-on experience in server infrastructure, system hardening, and performance tuning. Having worked across distributions such as Debian, Arch, RHEL, and Ubuntu, he brings real-world depth to every article published on this blog. r00t writes to bridge the gap between complex sysadmin concepts and practical, everyday application — whether you are configuring your first server or optimizing a production environment. Based in New York, US, he is a firm believer that knowledge, like open-source software, is best when shared freely.

Related Posts