🧰How to Install WP-CLI in cPanel with CageFS

Many customers who run WordPress websites in a cPanel hosting environment with CloudLinux and CageFS ask how to use WP-CLI — the command-line interface for WordPress.

Although some modern cPanel/CloudLinux servers may come with WP-CLI preinstalled, this guide is for system administrators who want to manually install and make WP-CLI available to cPanel users within CageFS.

🛠️ Prerequisites

  • Root access to a cPanel/WHM server.
  • CloudLinux with CageFS installed and configured.
  • cPanel users managed in a shared hosting environment.

✅ Step-by-Step Installation

1. SSH into the Server

Log in to your server as the root user:

ssh root@your-server-ip

2. Download and Install WP-CLI

Run the following commands to install WP-CLI globally:

cd ~
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
mv wp-cli.phar /usr/local/bin/wp

Now you should be able to run:

wp --info

This confirms that WP-CLI is installed.


3. Add WP-CLI to CageFS

To make WP-CLI available to all users inside CageFS, you must register the binary path.

Edit or create the following CageFS config file:

vim /etc/cagefs/conf.d/wpcli.cfg

Add the following content:

[wpcli]
comment=Allow wp-cli to work on the server
paths=/usr/local/bin/wp

4. Update CageFS

Run this command to update CageFS with the new settings:

cagefsctl --force-update

5. Test WP-CLI as a CageFS User

You can test by switching to a cPanel user that is inside CageFS:

su - username

Then check if WP-CLI is accessible:

wp --info

You should see the WP-CLI version and PHP environment info if everything is working correctly.


📌 Notes

  • If you need to allow more WP-CLI related binaries or scripts, append them in the same wpcli.cfg file under paths=.
  • WP-CLI requires WordPress to be installed in the working directory to run most commands. Ensure you’re inside the WordPress site path when using it.
  • This setup ensures that each cPanel user in CageFS has access to WP-CLI without giving them unrestricted access to system-level binaries.

🔗 Reference

Scroll to Top