Topic: Change default php version

Hi, I'm looking for a way to change my system's default php version on a CentOS 7 server.
Actually I installed 3 different php versions (5.6, 7.1 and 7.2) and I use php-fpm to run several application with all these 3 php version, but from command line seems like 7.1 is the default one.

[root@drakaris ~]#php -version
PHP 7.1.33 (cli) (built: Jan 23 2020 09:31:19) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.1.33, Copyright (c) 1999-2018, by Zend Technologies

[root@drakaris ~]#which php
/usr/local/sbin/php

[root@drakaris ~]#ls -la /usr/local/sbin/php
lrwxrwxrwx 1 root root 28 May  3  2019 /usr/local/sbin/php -> /opt/remi/php71/root/bin/php

My objective is to make php 7.2 the default cli version.

I found this command, but from my understanding it will affect only the bash started with the command itself, and not the default php version, is it right?

scl enable php72 bash

I also found another one using module command

module load php72

Do you think this one will work and will be persistent throught system reboot and will make 7.2 the default php version for the system?

Thanks

Re: Change default php version

> ls -la /usr/local/sbin/php
> lrwxrwxrwx 1 root root 28 May  3  2019 /usr/local/sbin/php -> /opt/remi/php71/root/bin/php

Change the link to the version you want.

BTW, see the Wizard instructions
https://rpms.remirepo.net/wizard/

There is explanation for "single/default" version and for "multiple" versions

If you only want to use SCL (and no php-* package, so no "single/default" version), you can install php72-syspath which create the needed links (of course, only one "syspath" package can be installed)

Desktop: Fedora 35 + rpmfusion + remi-test + remi-dev
Laptop:  Fedora 34 + rpmfusion + remi (SCL only)
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: Change default php version

> scl enable php72 bash
> module load php72

Both command are only for the current shell.

Desktop: Fedora 35 + rpmfusion + remi-test + remi-dev
Laptop:  Fedora 34 + rpmfusion + remi (SCL only)
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi