Running wp-cli with specific PHP version

Post Reply
User avatar
myVesta
Site Admin
Posts: 918
Joined: Fri Jun 19, 2020 9:59 am
Has thanked: 8 times
Been thanked: 6 times

To install wp-cli or get fresh version:

Code: Select all

wget -nv https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O /usr/local/bin/wp
chmod +x /usr/local/bin/wp
To run it with, for example, PHP 5.6, type:

Code: Select all

USER='someUsername'
sudo -H -u$USER /usr/bin/php5.6 /usr/local/bin/wp --info
Output will confirm the PHP version:

Code: Select all

OS:	Linux myhostmachine 4.19.0-18-amd64 #1 SMP Debian 4.19.208-1 (2021-09-29) x86_64
Shell:	/sbin/nologin
PHP binary:	/usr/bin/php5.6
PHP version:	5.6.40-57+0~20211119.60+debian10~1.gbp8a9bd1
php.ini used:	/etc/php/5.6/cli/php.ini
MySQL binary:	/usr/bin/mysql
MySQL version:	mysql  Ver 15.1 Distrib 10.3.31-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
SQL modes:	
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:	/home/someUsername/web/mysite.com/public_html
WP-CLI packages dir:	
WP-CLI global config:	
WP-CLI project config:	
WP-CLI version:	2.6.0
Post Reply