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:
- Create or edit a custom CageFS configuration file:
nano /etc/cagefs/conf.d/wp-cli.cfg
- 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.
- Temporarily set a valid shell (if needed):
chsh -s /bin/bash example
- Enter the user environment:
su - example
- 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