Changing the php version in virtual server>configuration>php options has no effect

Hello,

On a server of type:
Webmin version 1.994
Usermin version 1.840
Virtualmin version 7.1-1
Kernel and CPU Linux 4.9.0-18-amd64 on x86_64

With the following PHP versions installed:
/etc/php/7.4/cgi/php.ini PHP 7.4
/etc/php/8.0/cgi/php.ini PHP 8.0
/etc/php/8.1/cgi/php.ini PHP 8.1

for some time the only version of PHP detected is the highest (8.1)

On virtual server, I choose another version of php in virtual server > configuration > php options

But when I do php -v, the response is always:
php-v
PHP 8.1.7 (cli) (built: Jun 14 2022 10:27:12) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.7, Copyright (c) Zend Technologies
with Zend OPcache v8.1.7, Copyright (c), by Zend Technologies

I tried many modifications and checks, restarting apache and other suggestions, but nothing helped.
Maybe someone has experienced this before, has an idea or a suggestion.

Thanks in advance.

Hello,

Can you list all the system PHP packages that are installed?

I hope that’s what you’re asking me
Thanks in advance

|libapache2-mod-php8.0|8.0.20-1+0~20220614.37+debian9~1.gbp11fdd0|
|php-apcu-bc|1.0.5-14+0~20211115.22+debian9~1.gbpa00758|
|php-common|92+0~20220117.43+debian9~1.gbpe0d14e|
|php-fpm|8.1+92+0~20220117.43+debian9~1.gbpe0d14e|
|php-propro|2.1.0+1.0.2+nophp8-9+0~20211120.17+debian9~1.gbp2803a4|
|php7.4-apcu|5.1.21+4.0.11-7+0~20220117.31+debian9~1.gbp9a887a|
|php7.4-apcu-bc|1.0.5-14+0~20211115.22+debian9~1.gbpa00758|
|php7.4-bcmath|7.4.30-1+0~20220614.67+debian9~1.gbpf8212f|
|php7.4-bz2|7.4.30-1+0~20220614.67+debian9~1.gbpf8212f|
|php7.4-cgi|7.4.30-1+0~20220614.67+debian9~1.gbpf8212f|
|php7.4-cli|7.4.30-1+0~20220614.67+debian9~1.gbpf8212f|
|php7.4-common|7.4.30-1+0~20220614.67+debian9~1.gbpf8212f|
|php7.4-curl|7.4.30-1+0~20220614.67+debian9~1.gbpf8212f|
|php7.4-fpm|7.4.30-1+0~20220614.67+debian9~1.gbpf8212f|
|php7.4-gd|7.4.30-1+0~20220614.67+debian9~1.gbpf8212f|
|php7.4-gmp|7.4.30-1+0~20220614.67+debian9~1.gbpf8212f|
|php7.4-igbinary|3.2.7+2.0.8-1+0~20220421.34+debian9~1.gbp53e1f5|
|php7.4-imagick|3.6.0-4+0~20220117.35+debian9~1.gbp149f82|
|php7.4-imap|7.4.30-1+0~20220614.67+debian9~1.gbpf8212f|
|php7.4-intl|7.4.30-1+0~20220614.67+debian9~1.gbpf8212f|
|php7.4-json|7.4.30-1+0~20220614.67+debian9~1.gbpf8212f|
|php7.4-mbstring|7.4.30-1+0~20220614.67+debian9~1.gbpf8212f|
|php7.4-mcrypt|1.0.4-7+0~20211118.7+debian9~1.gbp26dfce|
|php7.4-memcache|8.0+4.0.5.2+3.0.9~20170802.e702b5f9±7+0~20220117.28+debian9~1.gbp8ceec4|
|php7.4-memcached|3.2.0+2.2.0-1+0~20220421.38+debian9~1.gbp96ecac|
|php7.4-msgpack|2.2.0~rc1+2.1.2+0.5.7-6+0~20220117.33+debian9~1.gbp304533|
|php7.4-mysql|7.4.30-1+0~20220614.67+debian9~1.gbpf8212f|
|php7.4-opcache|7.4.30-1+0~20220614.67+debian9~1.gbpf8212f|
|php7.4-phpdbg|7.4.30-1+0~20220614.67+debian9~1.gbpf8212f|
|php7.4-propro|2.1.0+1.0.2+nophp8-9+0~20211120.17+debian9~1.gbp2803a4|
|php7.4-pspell|7.4.30-1+0~20220614.67+debian9~1.gbpf8212f|
|php7.4-readline|7.4.30-1+0~20220614.67+debian9~1.gbpf8212f|
|php7.4-soap|7.4.30-1+0~20220614.67+debian9~1.gbpf8212f|
|php7.4-uploadprogress|2.0.2+1.1.4-6+0~20220117.24+debian9~1.gbp8012cb|
|php7.4-xml|7.4.30-1+0~20220614.67+debian9~1.gbpf8212f|
|php7.4-xmlrpc|7.4.30-1+0~20220614.67+debian9~1.gbpf8212f|
|php7.4-xsl|7.4.30-1+0~20220614.67+debian9~1.gbpf8212f|
|php7.4-zip|7.4.30-1+0~20220614.67+debian9~1.gbpf8212f|
|php8.0|8.0.20-1+0~20220614.37+debian9~1.gbp11fdd0|
|php8.0-apcu|5.1.21+4.0.11-7+0~20220117.31+debian9~1.gbp9a887a|
|php8.0-bcmath|8.0.20-1+0~20220614.37+debian9~1.gbp11fdd0|
|php8.0-cgi|8.0.20-1+0~20220614.37+debian9~1.gbp11fdd0|
|php8.0-cli|8.0.20-1+0~20220614.37+debian9~1.gbp11fdd0|
|php8.0-common|8.0.20-1+0~20220614.37+debian9~1.gbp11fdd0|
|php8.0-curl|8.0.20-1+0~20220614.37+debian9~1.gbp11fdd0|
|php8.0-fpm|8.0.20-1+0~20220614.37+debian9~1.gbp11fdd0|
|php8.0-gd|8.0.20-1+0~20220614.37+debian9~1.gbp11fdd0|
|php8.0-gmp|8.0.20-1+0~20220614.37+debian9~1.gbp11fdd0|
|php8.0-igbinary|3.2.7+2.0.8-1+0~20220421.34+debian9~1.gbp53e1f5|
|php8.0-imagick|3.6.0-4+0~20220117.35+debian9~1.gbp149f82|
|php8.0-imap|8.0.20-1+0~20220614.37+debian9~1.gbp11fdd0|
|php8.0-intl|8.0.20-1+0~20220614.37+debian9~1.gbp11fdd0|
|php8.0-mbstring|8.0.20-1+0~20220614.37+debian9~1.gbp11fdd0|
|php8.0-mcrypt|1.0.4-7+0~20211118.7+debian9~1.gbp26dfce|
|php8.0-memcache|8.0+4.0.5.2+3.0.9~20170802.e702b5f9±7+0~20220117.28+debian9~1.gbp8ceec4|
|php8.0-memcached|3.2.0+2.2.0-1+0~20220421.38+debian9~1.gbp96ecac|
|php8.0-msgpack|2.2.0~rc1+2.1.2+0.5.7-6+0~20220117.33+debian9~1.gbp304533|
|php8.0-mysql|8.0.20-1+0~20220614.37+debian9~1.gbp11fdd0|
|php8.0-opcache|8.0.20-1+0~20220614.37+debian9~1.gbp11fdd0|
|php8.0-pspell|8.0.20-1+0~20220614.37+debian9~1.gbp11fdd0|
|php8.0-readline|8.0.20-1+0~20220614.37+debian9~1.gbp11fdd0|
|php8.0-soap|8.0.20-1+0~20220614.37+debian9~1.gbp11fdd0|
|php8.0-uploadprogress|2.0.2+1.1.4-6+0~20220117.24+debian9~1.gbp8012cb|
|php8.0-xml|8.0.20-1+0~20220614.37+debian9~1.gbp11fdd0|
|php8.0-xmlrpc|1.0.0~rc3-4+0~20220117.10+debian9~1.gbp1325df|
|php8.0-xsl|8.0.20-1+0~20220614.37+debian9~1.gbp11fdd0|
|php8.0-zip|8.0.20-1+0~20220614.37+debian9~1.gbp11fdd0|
|php8.1-apcu|5.1.21+4.0.11-7+0~20220117.31+debian9~1.gbp9a887a|
|php8.1-bcmath|8.1.7-1+0~20220614.21+debian9~1.gbpb08a43|
|php8.1-cgi|8.1.7-1+0~20220614.21+debian9~1.gbpb08a43|
|php8.1-cli|8.1.7-1+0~20220614.21+debian9~1.gbpb08a43|
|php8.1-common|8.1.7-1+0~20220614.21+debian9~1.gbpb08a43|
|php8.1-curl|8.1.7-1+0~20220614.21+debian9~1.gbpb08a43|
|php8.1-fpm|8.1.7-1+0~20220614.21+debian9~1.gbpb08a43|
|php8.1-gd|8.1.7-1+0~20220614.21+debian9~1.gbpb08a43|
|php8.1-gmp|8.1.7-1+0~20220614.21+debian9~1.gbpb08a43|
|php8.1-igbinary|3.2.7+2.0.8-1+0~20220421.34+debian9~1.gbp53e1f5|
|php8.1-imagick|3.6.0-4+0~20220117.35+debian9~1.gbp149f82|
|php8.1-imap|8.1.7-1+0~20220614.21+debian9~1.gbpb08a43|
|php8.1-intl|8.1.7-1+0~20220614.21+debian9~1.gbpb08a43|
|php8.1-mbstring|8.1.7-1+0~20220614.21+debian9~1.gbpb08a43|
|php8.1-mcrypt|1.0.4-7+0~20211118.7+debian9~1.gbp26dfce|
|php8.1-memcache|8.0+4.0.5.2+3.0.9~20170802.e702b5f9±7+0~20220117.28+debian9~1.gbp8ceec4|
|php8.1-memcached|3.2.0+2.2.0-1+0~20220421.38+debian9~1.gbp96ecac|
|php8.1-msgpack|2.2.0~rc1+2.1.2+0.5.7-6+0~20220117.33+debian9~1.gbp304533|
|php8.1-mysql|8.1.7-1+0~20220614.21+debian9~1.gbpb08a43|
|php8.1-opcache|8.1.7-1+0~20220614.21+debian9~1.gbpb08a43|
|php8.1-phpdbg|8.1.7-1+0~20220614.21+debian9~1.gbpb08a43|
|php8.1-pspell|8.1.7-1+0~20220614.21+debian9~1.gbpb08a43|
|php8.1-readline|8.1.7-1+0~20220614.21+debian9~1.gbpb08a43|
|php8.1-soap|8.1.7-1+0~20220614.21+debian9~1.gbpb08a43|
|php8.1-uploadprogress|2.0.2+1.1.4-6+0~20220117.24+debian9~1.gbp8012cb|
|php8.1-xml|8.1.7-1+0~20220614.21+debian9~1.gbpb08a43|
|php8.1-xmlrpc|1.0.0~rc3-4+0~20220117.10+debian9~1.gbp1325df|
|php8.1-xsl|8.1.7-1+0~20220614.21+debian9~1.gbpb08a43|
|php8.1-zip|8.1.7-1+0~20220614.21+debian9~1.gbpb08a43|
|phpunit-git|2.1.3-1|
|webmin-php-pear|1.5|

@thierry1,

php -v

from the command line will always reference the “default” version.

*** default is typically the latest version ***

However, when you configure via the panel, it’ll use the version you switch to for that website in conjunction with the web server (Apache or Nginx).

If you are writing command line applications, you’ll need to specify the full path to the version of PHP you wish to make use of.

*** Professional, Affordable Virtualmin Assistance: https://tpnassist.com ***

@tpnsolutions

Thank you for your answer, but I’m not sure I understand your comment because on another server the php -v command returns the parameterized version of php.

Moreover my answers in this forum (for example the list of php packages that I posted) does not appear and I receive the message “Our automated spam filter, Akismet, has temporarily hidden your post in Changing the php version in virtual server>configuration>php options has no effect for review.”

Beyond that, what bothers me is that when I try to install an application on one of the virtual servers (and this is the case for all of them) for example :

composer create-project 

I always get a response

[InvalidArgumentException]  Could not find package  in a version installable using your PHP version, PHP extensions and Composer version.

Hope this helps someone to understand this problem.
Thanks

@Ilia

I hope that’s what you’re asking me Thanks in advance

ibapache2-mod-php8.0
php-apcu-bc
php-common
php-fpm
php-propro
php7.4-apcu
php7.4-apcu-bc
php7.4-bcmath
php7.4-bz2
php7.4-cgi
php7.4-cli
php7.4-common
php7.4-curl
php7.4-fpm
php7.4-gd
php7.4-gmp
php7.4-igbinary
php7.4-imagick
php7.4-imap
php7.4-intl
php7.4-json
php7.4-mbstring
php7.4-mcrypt
php7.4-memcache
php7.4-memcached
php7.4-msgpack
php7.4-mysql
php7.4-opcache
php7.4-phpdbg
php7.4-propro
php7.4-pspell
php7.4-readline
php7.4-soap
php7.4-uploadprogress
php7.4-xml
php7.4-xmlrpc
php7.4-xsl
php7.4-zip
php8.0
php8.0-apcu
php8.0-bcmath
php8.0-cgi
php8.0-cli
php8.0-common
php8.0-curl
php8.0-fpm
php8.0-gd
php8.0-gmp
php8.0-igbinary
php8.0-imagick
php8.0-imap
php8.0-intl
php8.0-mbstring
php8.0-mcrypt
php8.0-memcache
php8.0-memcached
php8.0-msgpack
php8.0-mysql
php8.0-opcache
php8.0-pspell
php8.0-readline
php8.0-soap
php8.0-uploadprogress
php8.0-xml
php8.0-xmlrpc
php8.0-xsl
php8.0-zip
php8.1-apcu
php8.1-bcmath
php8.1-cgi
php8.1-cli
php8.1-common
php8.1-curl
php8.1-fpm
php8.1-gd
php8.1-gmp
php8.1-igbinary
php8.1-imagick
php8.1-imap
php8.1-intl
php8.1-mbstring
php8.1-mcrypt
php8.1-memcache
php8.1-memcached
php8.1-msgpack
php8.1-mysql
php8.1-opcache
php8.1-phpdbg
php8.1-pspell
php8.1-readline
php8.1-soap
php8.1-uploadprogress
php8.1-xml
php8.1-xmlrpc
php8.1-xsl
php8.1-zip
phpunit-git
webmin-php-pear

thanks

@thierry1,

To demonstrate my point.

Type:

which php

It’ll show you the path to the default PHP version being used when you type “php” without a path.

If you want to run from the command line an alternate version you need to specify the path.

Running “php” without a path is running what the system deems the default version.

1 Like

If you want to change system default PHP version you can do this by using the following command:

update-alternatives --config php

@tpnsolutions

Hello,
and thank you for your answer which clarifies this point.

In order to specify the problem that I encounter, and to identify my error, I give an example of what I am trying to do.

the command virtualmin list-php-directories seems to return the correct value :

root@ekosysteme:~# virtualmin list-php-directories --domain social.ekosysteme.fr
Directory Version
-------------------------------------------------- -------------------- -------
/home/eko/domains/social.ekosysteme.fr/social-11/html 7.4

But the detected version does not seem to be the correct one :

eko@ekosysteme:~/domains/social.ekosysteme.fr/social-11$ composer update
Your requirements could not be resolved to an installable set of packages.
    - Root composer.json requires php ^7.4 but your php version (8.1.7) does not satisfy that requirement.

@Ilia
Thanks for your help !
doing update-alternatives --config php seems to do the job :
`root@ekosysteme:~# update-alternatives --config php
There are 3 choices for the php alternative (which provides /usr/bin/php).
Selection Path Priority Status


  • 0 /usr/bin/php8.1 81 automatic mode
    1 /usr/bin/php7.4 74 manual mode
    2 /usr/bin/php8.0 80 manual mode
    3 /usr/bin/php8.1 81 manual mode

Press to keep the default [*] or choose the selected number: 1
update-alternatives: using “/usr/bin/php7.4” to provide “/usr/bin/php” (php) in manual mode
root@ekosysteme:~# update-alternatives --config php
There are 3 choices for the php alternative (which provides /usr/bin/php).

Selection Path Priority Status


0 /usr/bin/php8.1 81 automatic mode

  • 1 /usr/bin/php7.4 74 manual mode
    2 /usr/bin/php8.0 80 manual mode
    3 /usr/bin/php8.1 81 manual mode`

Thank you for your answer which solves the problem stated above although it does not explain to me that the change of version of php by the virtualmin interface in virtual server> configuration> php options does not work. I didn’t seem to have encountered this problem with previous versions of php.

Thank you again and, for my part and for the moment, my problem is solved.
So this post can be marked as solved, but I don’t know how to do it.

Have a good day.

I had the same problem and it was caused by mod-php being installed.

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