How to enable wp-cli on a Cloudlinux / cPanel server

269ac00f765508cb74b25d006dbf5bb2

Written by Dennis Nind

Last published at: February 8th, 2019

This page describes how to install wp-cli in a cPanel/WHM server with CloudLinux, of course our cPanel comes with wp-cli preinstalled. This page should be used by system admins who want to make wp-cli available to their customers in cPanel with CloudLinux/CageFS installed. First, SSH to the cPanel/WHM server as the root user. Next, run these commands to install wp-cli:

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, as you have installed wp-cli, let’s add it to the CageFS so that users could access it

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

And add this content:

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

Next, update CageFS

cagefsctl --force-update

Test to see if it works, become a CageFS user.

su cagefsuser
wp --info