centos 7: replace php5.4 with php7


is there really a need for multiple versions of php? is it good enough to just have php7 only? if so, how can do?

php -v reports 5.4 but i'd like it to show 7.0

[root@server ~]# php -v
PHP 5.4.16 (cli) (built: Nov  6 2016 00:29:02)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

i installed php5.6 and php7 according to:

yum install -y scl-utils
rpm -Uvh https://www.softwarecollections.org/repos/rhscl/rh-php56/epel-7-x86_64/noarch/rhscl-rh-php56-epel-7-x86_64.noarch.rpm
yum install -y rh-php56 rh-php56-php-mysqlnd
yum install -y http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum install -y php70 php70-php-mysqlnd
yum install -y php70-php-devel php70-php-gd php70-php-json php70-php-mcrypt php70-php-mbstring php70-php-opcache php70-php-pear php70-php-pecl-apcu php70-php-pecl-geoip php70-php-pecl-imagick php70-php-pecl-json-post php70-php-pecl-memcache php70-php-pecl-xmldiff php70-php-pecl-zip php70-php-pspell php70-php-soap php70-php-tidy php70-php-xml php70-php-xmlrpc

resulting in:

[root@server ~]# find / -name php
[root@server ~]# yum list installed | grep php
php.x86_64                        5.4.16-42.el7            @base               
php-cli.x86_64                    5.4.16-42.el7            @base               
php-common.x86_64                 5.4.16-42.el7            @base               
php-gd.x86_64                     5.4.16-42.el7            @base               
php-imap.x86_64                   5.4.16-7.el7             @epel               
php-mbstring.x86_64               5.4.16-42.el7            @base               
php-mysql.x86_64                  5.4.16-42.el7            @base               
php-odbc.x86_64                   5.4.16-42.el7            @base               
php-pdo.x86_64                    5.4.16-42.el7            @base               
php-pear.noarch                   1:1.9.4-21.el7           @base               
php-pgsql.x86_64                  5.4.16-42.el7            @base               
php-process.x86_64                5.4.16-42.el7            @base               
php-snmp.x86_64                   5.4.16-42.el7            @base               
php-xml.x86_64                    5.4.16-42.el7            @base               
php-xmlrpc.x86_64                 5.4.16-42.el7            @base               
php70.x86_64                      1.0-5.el7.remi           @remi-safe          
php70-php-cli.x86_64              7.0.14-1.el7.remi        @remi-safe          
php70-php-common.x86_64           7.0.14-1.el7.remi        @remi-safe          
php70-php-devel.x86_64            7.0.14-1.el7.remi        @remi-safe          
php70-php-gd.x86_64               7.0.14-1.el7.remi        @remi-safe          
php70-php-json.x86_64             7.0.14-1.el7.remi        @remi-safe          
php70-php-mbstring.x86_64         7.0.14-1.el7.remi        @remi-safe          
php70-php-mcrypt.x86_64           7.0.14-1.el7.remi        @remi-safe          
php70-php-mysqlnd.x86_64          7.0.14-1.el7.remi        @remi-safe          
php70-php-opcache.x86_64          7.0.14-1.el7.remi        @remi-safe          
php70-php-pdo.x86_64              7.0.14-1.el7.remi        @remi-safe          
php70-php-pear.noarch             1:1.10.1-7.el7.remi      @remi-safe          
php70-php-pecl-apcu.x86_64        5.1.7-1.el7.remi         @remi-safe          
php70-php-pecl-apcu-bc.x86_64     1.0.3-1.el7.remi         @remi-safe          
php70-php-pecl-geoip.x86_64       1.1.1-1.el7.remi         @remi-safe          
php70-php-pecl-imagick.x86_64     3.4.3-0.4.RC1.el7.remi   @remi-safe          
php70-php-pecl-json-post.x86_64   1.0.1-3.el7.remi         @remi-safe          
php70-php-pecl-memcache.x86_64    3.0.9-0.7.20161124gitdf7735e.el7.remi
php70-php-pecl-xmldiff.x86_64     1.1.2-6.el7.remi         @remi-safe          
php70-php-pecl-zip.x86_64         1.13.5-1.el7.remi        @remi-safe          
php70-php-process.x86_64          7.0.14-1.el7.remi        @remi-safe          
php70-php-pspell.x86_64           7.0.14-1.el7.remi        @remi-safe          
php70-php-soap.x86_64             7.0.14-1.el7.remi        @remi-safe          
php70-php-tidy.x86_64             7.0.14-1.el7.remi        @remi-safe          
php70-php-xml.x86_64              7.0.14-1.el7.remi        @remi-safe          
php70-php-xmlrpc.x86_64           7.0.14-1.el7.remi        @remi-safe          
php70-runtime.x86_64              1.0-5.el7.remi           @remi-safe          
rh-php56.x86_64                   2.0-6.el7.centos         @rhscl-rh-php56-epel-7-x86_64
rh-php56-php-cli.x86_64           5.6.5-7.el7.centos       @rhscl-rh-php56-epel-7-x86_64
rh-php56-php-common.x86_64        5.6.5-7.el7.centos       @rhscl-rh-php56-epel-7-x86_64
rh-php56-php-mysqlnd.x86_64       5.6.5-7.el7.centos       @rhscl-rh-php56-epel-7-x86_64
rh-php56-php-pdo.x86_64           5.6.5-7.el7.centos       @rhscl-rh-php56-epel-7-x86_64
rh-php56-php-pear.noarch          1:1.9.5-3.el7.centos     @rhscl-rh-php56-epel-7-x86_64
rh-php56-php-pecl-jsonc.x86_64    1.3.6-3.el7.centos       @rhscl-rh-php56-epel-7-x86_64
rh-php56-php-process.x86_64       5.6.5-7.el7.centos       @rhscl-rh-php56-epel-7-x86_64
rh-php56-php-xml.x86_64           5.6.5-7.el7.centos       @rhscl-rh-php56-epel-7-x86_64
rh-php56-runtime.x86_64           2.0-6.el7.centos         @rhscl-rh-php56-epel-7-x86_64
wbm-php-pear.noarch               2:1.6-1                  @virtualmin-universal

i also ran scl:

[root@server ~]# scl enable php70 'php -v'
PHP 7.0.14 (cli) (built: Dec  7 2016 09:19:11) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.14, Copyright (c) 1999-2016, by Zend Technologies

i researched: https://www.virtualmin.com/node/35500 https://www.virtualmin.com/node/39000 http://serverfault.com/questions/706349/install-php7-from-remi-repo https://www.virtualmin.com/node/38648

shall i remove the old php5.4 and 5.6 and then add a symlink to pointing to /opt/remi/php70? if so what would be the command?



Howdy -- the issue there is related to the repository the packages come from.

There's only two repositories we recommend -- the standard CentOS repository, and the SCL repository.

We've seen a variety of problems occur with other third party repositories, and for that reason we don't recommend any others.

My suggestion in your case would be to just install PHP 7 from the CentOS SCL repository (as you may have done? Though if that didn't come from the SCL repo I wouldn't change it now :-), and if you don't need PHP 5.4 -- no problem, I just wouldn't use it.

I wouldn't recommend removing the old PHP versions though -- that's not something we've tested, and it's possible removing that could end up removing dependencies that are necessary for one reason or another.

You're going to find that some non-trivial amount of very common software will not run reliably under PHP 7 - so you really need to know what you're going to be supporting on the server and whether 7 will work with it or not. Personally I would definitely keep the distributed version of PHP on the server.