Sample Header Ad - 728x90

No update-alternatives in AlmaLinux 8 for PHP

-1 votes
1 answer
822 views
I run the command
-alternatives --config php
and nothing shows up. I checked for the binaries and they are executables in the
/usr/bin
folder. Installed PHP versions are 7.4 from the AppStream repository and PHP 5.6 from the REMI repository.
ll /usr/bin/php*
-rwxr-xr-x. 1 root root 6376328 Oct 11 01:34 /usr/bin/php
lrwxrwxrwx  1 root root      32 Feb 15 21:31 /usr/bin/php56 -> /opt/remi/php56/root/usr/bin/php
lrwxrwxrwx  1 root root      36 Feb 15 21:31 /usr/bin/php56-cgi -> /opt/remi/php56/root/usr/bin/php-cgi
lrwxrwxrwx  1 root root      33 Aug 11  2021 /usr/bin/php56-pear -> /opt/remi/php56/root/usr/bin/pear
lrwxrwxrwx  1 root root      38 Feb 15 21:31 /usr/bin/php56-phar -> /opt/remi/php56/root/usr/bin/phar.phar
-rwxr-xr-x. 1 root root 6375784 Oct 11 01:34 /usr/bin/php-cgi
-rwxr-xr-x. 1 root root    4741 Oct 11 01:34 /usr/bin/phpize
With Java, I noticed they are symlinks to
.
[root@alma8-webapps-dev alternatives]# ll /usr/bin/java*
lrwxrwxrwx. 1 root root 22 Feb 10 00:39 /usr/bin/java -> /etc/alternatives/java
lrwxrwxrwx. 1 root root 23 Feb 10 00:39 /usr/bin/javac -> /etc/alternatives/javac
lrwxrwxrwx. 1 root root 25 Feb 10 00:39 /usr/bin/javadoc -> /etc/alternatives/javadoc
lrwxrwxrwx. 1 root root 23 Feb 10 00:39 /usr/bin/javap -> /etc/alternatives/javap
One option is to rename the PHP 7.4 files, so I'll rename them as follows:
mv /usr/bin/php /usr/bin/php74 
mv /usr/bin/php-cgi /usr/bin/php74-cgi
After that, I create new alternatives:
alternatives --install /usr/bin/php php /usr/bin/php74 1
alternatives --install /usr/bin/php php /usr/bin/php56 2
alternatives --install /usr/bin/php-cgi php-cgi /usr/bin/php74-cgi 1
alternatives --install /usr/bin/php-cgi php-cgi /usr/bin/php56-cgi 2
The entries are now in alternatives:
update-alternatives --config php

There are 2 programs which provide 'php'.

  Selection    Command
-----------------------------------------------
   1           /usr/bin/php74
*+ 2           /usr/bin/php56

Enter to keep the current selection[+], or type selection number:
It has created symlinks to alternatives
ll /usr/bin/php*
lrwxrwxrwx  1 root root      21 Feb 17 19:56 /usr/bin/php -> /etc/alternatives/php
lrwxrwxrwx  1 root root      32 Feb 15 21:31 /usr/bin/php56 -> /opt/remi/php56/root/usr/bin/php
lrwxrwxrwx  1 root root      36 Feb 15 21:31 /usr/bin/php56-cgi -> /opt/remi/php56/root/usr/bin/php-cgi
lrwxrwxrwx  1 root root      33 Aug 11  2021 /usr/bin/php56-pear -> /opt/remi/php56/root/usr/bin/pear
lrwxrwxrwx  1 root root      38 Feb 15 21:31 /usr/bin/php56-phar -> /opt/remi/php56/root/usr/bin/phar.phar
-rwxr-xr-x. 1 root root 6376328 Oct 11 01:34 /usr/bin/php74
-rwxr-xr-x. 1 root root 6375784 Oct 11 01:34 /usr/bin/php74-cgi
lrwxrwxrwx  1 root root      25 Feb 17 19:59 /usr/bin/php-cgi -> /etc/alternatives/php-cgi
-rwxr-xr-x. 1 root root    4741 Oct 11 01:34 /usr/bin/phpize
I tested updating PHP and it says PHP is no longer installed.
dnf update php
Last metadata expiration check: 0:28:58 ago on Fri 17 Feb 2023 07:41:07 PM AEDT.
Package php available, but not installed.
No match for argument: php
Error: No packages marked for upgrade.
How would I get alternatives to work with multiple versions of PHP and still be able to perform updates?
Asked by supmethods (561 rep)
Feb 17, 2023, 09:03 AM
Last activity: Feb 17, 2023, 02:50 PM