WP-CLI » Download WP-CLI & set custom PHP Version

Download WP-CLI & set custom PHP Version

Recently I was migrating a website from GoDaddy shared hosting using WP-CLI and noticed the PHP version in cli was outdated.

Here is how to install WP-CLI and set custom PHP version for the cli.

To download WP cli:

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

To run it use php wp-cli.phar

php wp-cli.phar --info

To make it easier to call We’ll rename it to wp:

sudo mv wp-cli.phar wp

and make it executable:

chmod +x wp

To add WP-CLI to path run:

export PATH=</path/to/wp-cli/directory>:$PATH

and afterwards you can use the wp command inside any directory

wp --info

From the terminal run

See also  List all shortcodes from all WordPress posts with WPCLI
php -version

Or, create an info.php page with phpinfo(); and under Configure Command options look for bindir


Set the WP_CLI_PHP environment variable to the desired PHP version:

export WP_CLI_PHP=/opt/php81/bin

Was this post helpful?

Leave a Comment

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.