πŸ› οΈ How to Add the WordPress Command-Line Tool (WP-CLI) for CageFS Users on CloudLinux


WP-CLI enables powerful WordPress management via terminal. Integrating it into CageFS ensures shared hosting users can safely access it in a restricted environment.


πŸ“Œ Step 1: Download and Install WP-CLI

First, install WP-CLI globally:

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

πŸ” Test it:

wp --info

You should see version and environment info confirming the tool works.


πŸ“Œ Step 2: Configure CageFS to Include WP-CLI

CageFS requires explicit permission to expose binaries to users. Add the path to WP-CLI:

  1. Create or edit a custom CageFS configuration file:
nano /etc/cagefs/conf.d/wp-cli.cfg
  1. Add the following content:
[wpcli]
comment=Enable WP-CLI for users
paths=/usr/local/bin/wp

πŸ’‘ Make sure /usr/local/bin/wp exists and is executable.


πŸ“Œ Step 3: Force CageFS to Refresh Its Filesystem

Run the following to rebuild the CageFS skeleton and mount new changes:

cagefsctl --force-update

βœ”οΈ Output should include:

Copying /usr/local/bin/wp to /usr/share/cagefs-skeleton/usr/local/bin/wp

πŸ“Œ Step 4: Test as a CageFS User

Let’s test WP-CLI from within a real user’s jailed shell.

  1. Temporarily set a valid shell (if needed):
chsh -s /bin/bash example
  1. Enter the user environment:
su - example
  1. Run:
wp --info

You should see details about WP-CLI. This confirms it’s working inside CageFS.

βœ… Optional: Revert user shell to /usr/local/cpanel/bin/noshell after testing.


βœ… Final Checks

  • PHP versions: WP-CLI uses the system default php. Use PHP Selector if your users require a different version.
  • PATH access: Ensure /usr/local/bin is in users’ $PATH.
  • Permissions: File should be world-readable/executable and not owned by cagefs users.

πŸ“… Last Verified On

  • CloudLinux: 9.5
  • cPanel: 126.x
  • WP-CLI: Latest (2025 build)
  • LiteSpeed Enterprise + Imunify360
Scroll to Top