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.
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.
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
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
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).
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.