How to install WP-CLI on litespeed

#1
Hi i have tried several times but each time the PHP Binary and php.ini used do not relate to litespeed server. If i install the wp-cli.phar inside the wordpress directory the following output from:

Code:
php wp-cli.phar --info
is this:

Code:
OS:     Linux 5.4.0-73-generic #82-Ubuntu SMP Wed Apr 14 17:39:42 UTC 2021 x86_64
Shell:  /bin/bash
PHP binary:     /usr/bin/php7.4
PHP version:    7.4.3
php.ini used:   /etc/php/7.4/cli/php.ini
MySQL binary:   /usr/bin/mysql
MySQL version:  mysql  Ver 15.1 Distrib 10.3.29-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
SQL modes:      STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
WP-CLI root dir:        phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:      phar://wp-cli.phar/vendor
WP_CLI phar path:       /usr/local/lsws/wordpress
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.5.0
Can anyone point out why WP-CLI is not finding the correct php.ini

Many thanks
 

Pong

Administrator
Staff member
#2
PHP Binary and php.ini are seperate with web server, no matter apache or LiteSpeed. wp-cli just use command mode of PHP, whatever is defined in the system.

In your above example, "php" command will look for system defined one, which is
/usr/bin/php7.4, if not that one, which one you prefer to use then? You can push full command there with your preferred full php path.
 
Last edited:
#3
Hi Pong, i am not sure i understand. This is how i have tried to install it

Inside the VHOST main wordpress folder where the wp-config file is:

Code:
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

php wp-cli.phar --info

#returns output as above post

chmod +x wp-cli.phar

mv wp-cli.phar /usr/local/bin/wp

wp --info

#returns output as above post
Then when i try to run a command from inside wordpress folder such as

Code:
wp plugin list
I get:

Code:
Error: YIKES! It looks like you're running this as root. You probably meant to run this as the user that your WordPress installation exists under.

If you REALLY mean to run this as root, we won't stop you, but just bear in mind that any code on this site will then have full control of your server, making it quite DANGEROUS.

If you'd like to continue as root, please run this again, adding this flag:  --allow-root

If you'd like to run it as the user that this site is under, you can run the following to become the respective user:

    sudo -u USER -i -- wp <command>
But even if i try to run the command as root using --allow-root (which i know is not advised but i just want to see if i can get it to work), i get:

Code:
Error: Your PHP installation appears to be missing the MySQL extension which is required by WordPress.
But i know i have the extension as lsphp is all upto date and mariadb is working fine. Litespeed is working fine.

Pong, if i may ask, how would you install wp-cli on wordpress on ubuntu 20.04

Many Thanks
 
#5
Hi Pong, not sure what you mean by "It is not about wp-cli installation". However, i would have thought that the php i would want to use would be the Litespeed php, but no matter how i try to install it, it just does not work, recognize or automatically pick up (which according to the documentation it is supposed to do) Litespeed php.

It should be a relatively easy procedure. If you do know how it is supposed to be installed on Litespeed i would be very grateful if you could explain that procedure. I can not find any Litespeed docs that explain how to install it. I know it must work as i have found threads with people who are using it, and Litespeed docs has a section on how to use wp-cli commands with Litespeed. But there is no documentation on installation.

Many Thanks
 

Pong

Administrator
Staff member
#6
LiteSpeed web server will use lsphp when user visit browser. but for cli mode, it doesn't matter lsphp or php, both should work. Since the information you provide is insufficient for us to understand your situation/your php installation path, you can log a ticket with us by sending email to support@litespeedtech.com, we can login to your server and check for you. basically, you want to fix "MySQL extension missing issue", right?
 
Top