How to change php cli version from 8.0 to 8.2?

As far as i understood, 8.0 is used by default… I added 8.2, set to use by servers in template, but php -v is still 8.0…

How can I change php cli version from 8.0 to 8.2?

Need to be used by cron jobs, minumum requirements by some applications like selfhosted invoicing software

thanks abd regards

Webmin adds a php.ini in /home/domain/etc which is a symlink to the version of php that webmin deems fit, just change that symlink to point to the version of php you want or just delete it. If deleted your OS will select the version of php that is default for the server. I mentioned this to the developers of webmin over a year ago but to be fair nothing has changed so I guess it’s not on the to do list, remember if you change the php version for the domain the symlink will reappear pointing to the version selected so maybe you will need to alter/delete it if you change the php version via the webmin gui. I see this as a bug rather than a feature

1 Like

on ubuntu:

  • When you install a newer version of PHP-CLI this will change the system default PHP to this new version and you will need to manually change it back using a command such as update-alternatives if required.
  • When you remove the system default PHP-CLI, the highest remaining PHP version will become the new system default.
  • update-alternatives does not change what Virtualmin considers the default. For that, you can choose it in Virtualmin --> Server Templates --> PHP Options. + this is only used at virtual server creation time.
  • After a Virtual Server has been created you change the PHP version by editing the virtual server.

You can manually change the OS default PHP version for the command line using update-alternatives

The PHP-CLI is what you get when you run commands in the terminal so you can see one version there and another when you do php_info() on a client’s website.

Only the PHP-CLI has a default, for each virtual server the PHP interpreter has to be specified so there is not really a default for them except the one you set in the server template.

When running cron jobs, you can specify a particular PHP version (as long as it is installed) to run the command, but I don’t know top of my head how to do that.

1 Like

Ok ignore what I said I’m just a php cli programmer that has hit the issue, but your theory may work as long as you remove the symlink outlined above

Thanks, i am copypaste level user, can you guide the command “update-alternative” to use php 8.2 as default or to delete present default 8.0 version? I use almalinux 9

?

Thanks and regards

Thanks, i managed to delete 8.0 and install 8.2. Thanks!!!

1 Like