# Change wp-cli PHP version in devkinsta\_fpm container?

**URL:** <https://community.kinsta.com/t/change-wp-cli-php-version-in-devkinsta-fpm-container/4326>\
**Category:** Questions\
**Created:** [November 8, 2024, 3:45am UTC](https://community.kinsta.com/t/change-wp-cli-php-version-in-devkinsta-fpm-container/4326 "2024-11-08T03:45:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryanb](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/ryanb/32/611_2.png) [@ryanb](https://community.kinsta.com/u/ryanb)\
**Post date:** [November 8, 2024, 3:45am UTC](https://community.kinsta.com/t/change-wp-cli-php-version-in-devkinsta-fpm-container/4326/1 "2024-11-08T03:45:15Z")

</div>

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.

```auto
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?

---

<div class="post-metadata">

**Author:** ![Agus](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/agus/32/1515_2.png) [@Agus](https://community.kinsta.com/u/Agus)\
**Post date:** [November 8, 2024, 4:27am UTC](https://community.kinsta.com/t/change-wp-cli-php-version-in-devkinsta-fpm-container/4326/2 "2024-11-08T04:27:21Z")

</div>

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:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/kinsta/original/2X/e/ed12a46bd33d2b726514c3221ed47e71269c7dbc.png)

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? 🙏

Best regards,  
Agus Utomo

---

<div class="post-metadata">

**Author:** ![ryanb](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/ryanb/32/611_2.png) [@ryanb](https://community.kinsta.com/u/ryanb)\
**Post date:** [November 8, 2024, 4:41am UTC](https://community.kinsta.com/t/change-wp-cli-php-version-in-devkinsta-fpm-container/4326/3 "2024-11-08T04:41:57Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/kinsta/original/2X/8/80f8c4e56fecc02327a0964e6bf63a716483529f.png) [@system](https://community.kinsta.com/u/system)\
**Post date:** [November 10, 2024, 4:42pm UTC](https://community.kinsta.com/t/change-wp-cli-php-version-in-devkinsta-fpm-container/4326/4 "2024-11-10T16:42:14Z")

</div>

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