Install WP-CLI (If Missing)
If WP-CLI is not installed, install it using the following command:
wget -O /usr/local/bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar chmod a+x /usr/local/bin/wp wget -O /etc/bash_completion.d/wp-completion.bash https://raw.githubusercontent.com/wp-cli/wp-cli/v2.4.0/utils/wp-completion.bash source /etc/bash_completion.d/wp-completion.bash
Enable WP-CLI Inside CageFS
To allow users inside CageFS to access WP-CLI, create a configuration file:
echo "[wp-cli] comment=WP-CLI inside CageFS. paths=/usr/local/bin/wp" > /etc/cagefs/conf.d/wp-cli.cfg
Apply Changes to CageFS
Run the following command to update CageFS:
cagefsctl --force-update
Verify WP-CLI as a User
Switch to a CageFS-enabled user and test WP-CLI:
su - username wp --info
If WP-CLI is still not found, try enabling CageFS for the user and reapply updates:
cagefsctl --enable username cagefsctl --force-update
Then, check again:
wp --info
Important Notes
✅ This solution is only for CloudLinux servers using CageFS.
✅ Ensure the user is inside CageFS for WP-CLI to work properly.
This method ensures WP-CLI is installed and accessible for users in CageFS on CloudLinux servers. 🚀