Change wp-cli PHP version in devkinsta_fpm container?

I’m unable to use wp-cli in the devkinsta_fpm docker container because my site requires PHP 8.1 but the default PHP in the container is 7.4.

www-data@f04de6273eca:/www/kinsta/public$ ls -l /etc/alternatives/php
lrwxrwxrwx 1 root root 15 Mar 14  2024 /etc/alternatives/php -> /usr/bin/php7.4

So when I run the wp command it crashes on the website code that requires 8.1. Is there a way to run wp-cli in the container with PHP 8.1?

Hello @ryanb

Thank you for the question above.

In that local docker container , could you please run this command (run as root ):
update-alternatives --config php
it would show you to change the PHP version (7.4) to 8.1 for example, something like this:

once changed to PHP 8.1 , you may want to try to run the WP CLI again with your WP site which requires PHP 8.1 and see if that would work properly as expected? :pray:

Best regards,
Agus Utomo

When I tried that before I got a permission denied error and when I tried with sudo I didn’t know the password. Then when you said (run as root) it occurred to me, I have been going into the container as www-data so that when I created files they would be owned by the web server. I went in again as root and it worked. Thanks!

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.