How to add the wordpress command line tool wp-cli for CageFS users on CloudLinux

To start we need to download the wp-cli php archive (phar) file and move it a logical folder of our choice with exicute permissions:

curl -O
mv wp-cli.phar /usr/local/bin/wp
chmod +x /usr/local/bin/wp

Next the path needs to be added to the cloud linux configuration file, you can do this by modifying the existing binunitls config file. edit '/etc/cagefs/conf.d/binutils.cfg' with a text editor of your choice such as vi or nano:

nano /etc/cagefs/conf.d/binutils.cfg

Add the following to the bottom of the file with the path using the path you chose in the move (mv) command above:

comment=custom paths

Next, we need cagefsctl to pick up the change by running the following command:

cagefsctl --force-update

You will see a number of files checked but you should see your path at the bottom as follows:

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


You can test this in a user shell by joining it with su. For this example we will assume you have a user on the system called 'example' and in our case the user was not given a system shell so we assign one with -s. then test we are the user with 'whoami' and check for the file with 'stat':

su -s /bin/bash example
stat /usr/local/bin/wp

Last Tested — 2019-11-11 16:17:03

Test Environment:

  • cPanel v84.0.7 [84.0 (build 7)]
  • Centos/CloudLinux 7.7