Two versions of PHP installed?


NethServer Version: NethServer release 7.6.1810 (final)
Module: php.x86_64 and rh-php71.x86_64

Looks like I have two versions of php installed (?)

# dnf list --installed | grep php
nethserver-php.noarch                 1.2.0-1.ns7                       @System
nethserver-rh-php71-php-fpm.noarch    1.0.0-1.ns7                       @System
php.x86_64                            5.4.16-46.el7                     @System
php-cli.x86_64                        5.4.16-46.el7                     @System
php-common.x86_64                     5.4.16-46.el7                     @System
php-fedora-autoloader.noarch          1.0.0-1.el7                       @System
php-icewind-smb.noarch                1.1.2-1.el7                       @System
php-icewind-streams.noarch            0.5.2-1.el7                       @System
php-intl.x86_64                       5.4.16-46.el7                     @System
php-mbstring.x86_64                   5.4.16-46.el7                     @System
php-pear.noarch                       1:1.9.4-21.el7                    @System
php-process.x86_64                    5.4.16-46.el7                     @System
php-smbclient.x86_64                  0.9.0-1.el7                       @System
php-xml.x86_64                        5.4.16-46.el7                     @System
rh-php71.x86_64                       1-1.el7                           @System
rh-php71-php-cli.x86_64               7.1.8-1.el7                       @System
rh-php71-php-common.x86_64            7.1.8-1.el7                       @System
rh-php71-php-fpm.x86_64               7.1.8-1.el7                       @System
rh-php71-php-gd.x86_64                7.1.8-1.el7                       @System
rh-php71-php-intl.x86_64              7.1.8-1.el7                       @System
rh-php71-php-json.x86_64              7.1.8-1.el7                       @System
rh-php71-php-ldap.x86_64              7.1.8-1.el7                       @System
rh-php71-php-mbstring.x86_64          7.1.8-1.el7                       @System
rh-php71-php-mysqlnd.x86_64           7.1.8-1.el7                       @System
rh-php71-php-opcache.x86_64           7.1.8-1.el7                       @System
rh-php71-php-pdo.x86_64               7.1.8-1.el7                       @System
rh-php71-php-pear.noarch              1:1.10.4-1.el7                    @System
rh-php71-php-pecl-apcu.x86_64         5.1.8-1.el7                       @System
rh-php71-php-process.x86_64           7.1.8-1.el7                       @System
rh-php71-php-xml.x86_64               7.1.8-1.el7                       @System
rh-php71-php-zip.x86_64               7.1.8-1.el7                       @System
rh-php71-runtime.x86_64               1-1.el7                           @System
sclo-php71-php-mcrypt.x86_64          7.1.11-1.el7                      @System
sclo-php71-php-pecl-imagick.x86_64    3.4.3-2.el7                       @centos-sclo-sclo
sclo-php71-php-smbclient.x86_64       0.9.0-2.el7                       @System

However, default is old enough to be causing issues with my shiny new installation of Nextcloud 15:

# php --version
PHP 5.4.16 (cli) (built: Oct 30 2018 19:30:51)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

Further evidence of dual php installation:

# find / -name php

How do I make /opt/rh/rh-php71/root/usr/bin/php default? Can I just uninstall php 5.4 and ln -s ? Are there any reasons this is ill-advised for Nethserver?


It shouldn’t be; Nextcloud (if installed through the software center) uses the 7.1 version.

ohh… I installed it through the web gui, but then I just upgraded it using dnf… mayhaps that’s me problem.

You can have several version of php from the software collection, I made also a rpm for that

And thanks for that :slight_smile:

But it seems that you are using remi-safe repo and Nextcloud RPM uses redhat/centos repos. So I use your RPM and nextcloud, so I have double PHP SCL installs (see /opt/rh and /opt/remi). So one more admin task to keep track of which version is being used by what module :slight_smile:

Have the same config. Remi as well as rh-scl modules from the Nextcloud installation.
What bothers me is that the rh-scl modules do not update. It’s a 16 months old version.

[root@serverxxx]# sudo -u apache scl enable rh-php71 'php -v'
PHP 7.1.8 (cli) (built: Aug  9 2017 13:20:06) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.1.8, Copyright (c) 1999-2017, by Zend Technologies

Both 56 and 71 versions are from the centos-sclo-rh repositories.

rh-php71.x86_64                     1-1.el7                  @centos-sclo-rh 
rh-php71-php-cli.x86_64             7.1.8-1.el7              @centos-sclo-rh  
rh-php71-php-common.x86_64          7.1.8-1.el7              @centos-sclo-rh
rh-php71-php-fpm.x86_64             7.1.8-1.el7              @centos-sclo-rh
rh-php71-runtime.x86_64             1-1.el7                  @centos-sclo-rh

[root@serverxxx]# yum --enablerepo=centos-sclo-rh update
Loaded plugins: changelog, fastestmirror, nethserver_events  
Loading mirror speeds from cached hostfile
* ce-base:
* ce-extras:
* ce-updates:
* epel:
* nethforge:
* nethserver-base:
* nethserver-updates:
No packages marked for update

Is it possible to have nextcloud use the remi php versions?

I second that request. Maybe @alep and team will consider this option? It would make SCL more consistent and will avoid confusion and possibly mistakes. Let alone possible security risks…


not tested, just for fun, this is how you load rh-php-scl

the idea could be to use the port of my phpscl

# config show php73-php-fpm

set it to the port 9001 and remove the port 9001 for the official rh scl


yum install php73-php-opcache --enablerepo=remi-safe

the template
should be cp to /etc/opt/remi/php73/php.d/10-opcache.ini (or modify accordingly the config file manually)


systemctl restart php73-php-fpm httpd

@stephdl, any chance you can work together on this with @alep and team?

Don’t know, probably a stable repo could be better than a bleeding edge one

But if a stable repo lacks the many php modules…

That was too easy:

Internal Server Error

Searching for error logs, did not find any (yet).

At pointer where to find the php config file in the wiki for nextcloud.
Nextcloud 14 occ commands generates a memory_limit error to low on 128M.

Fix it. Errors where caused by opcache not enabled.

Created a custom template to point to php71-php-fpm (port 9071).
I don’t need 7.3. Copied the opcache ini file from the nextcloud installation.
Installed php71 dependancies for Nextcloud from remi-safe (compare modules from yum list installed|grep php71 or find nextcloud deps info)

cp /etc/e-smith/templates/etc/httpd/conf.d/zz_nextcloud.conf/10base /etc/e-smith/templates-custom/etc/httpd/conf.d/zz_nextcloud.conf/10base

Edit this file to match php fpm version and port (I used the 7.1 version, php71-php-fpm and port 9071)

cp /etc/opt/rh/rh-php71/php.d/20-opcache.ini /etc/opt/remi/php71/php.d/.
signal-event nethserver-nextcloud-update
systemctl restart php71-php-fpm

Try nextcloud and check error logs

tail -f /var/opt/remi/php71/log/php-fpm/error.log
tail -f /var/lib/nethserver/nextcloud/nextcloud.log

Thanks for the infos

1 Like

This is wonderful. I’m going to try it on my production machine (it’s a gateway! :wink: )

I’ve been reading up on this and I came across a couple good solutions, unrelated there’s the rh scl devtoolsets - which I installed gcc 7 to go along with my new elrepo kernel-ml so I wouldn’t have an incompatible toolchain, and I found the php equivalent here

The instructions are easy. Here’s where we start, install php 72 (scl repository enabled by default in Nethserver):

# php --version
PHP 5.4.16 (cli) (built: Oct 30 2018 19:30:51)
Copyright (c) 1997-2013 The PHP Group

]# dnf install rh-php72
Last metadata expiration check: 0:00:09 ago on Sun 30 Dec 2018 06:38:04 AM PST.
Dependencies resolved.
 Package                 Arch      Version              Repository         Size
 rh-php72                x86_64    1-2.el7              centos-sclo-rh    4.3 k
Installing dependencies:
 rh-php72-php-cli        x86_64    7.2.10-3.el7         centos-sclo-rh    2.9 M
 rh-php72-php-common     x86_64    7.2.10-3.el7         centos-sclo-rh    672 k
 rh-php72-php-json       x86_64    7.2.10-3.el7         centos-sclo-rh     54 k
 rh-php72-php-pear       noarch    1:1.10.5-1.el7       centos-sclo-rh    357 k
 rh-php72-php-process    x86_64    7.2.10-3.el7         centos-sclo-rh     62 k
 rh-php72-php-xml        x86_64    7.2.10-3.el7         centos-sclo-rh    160 k
 rh-php72-php-zip        x86_64    7.2.10-3.el7         centos-sclo-rh     90 k
 rh-php72-runtime        x86_64    1-2.el7              centos-sclo-rh    1.1 M

Transaction Summary
Install  9 Packages

Total download size: 5.4 M
Installed size: 18 M
Is this ok [y/N]: y
Downloading Packages:
(1/9): rh-php72-1-2.el7.x86_64.rpm               20 kB/s | 4.3 kB     00:00
(2/9): rh-php72-php-pear-1.10.5-1.el7.noarch.rp 335 kB/s | 357 kB     00:01
(3/9): rh-php72-php-common-7.2.10-3.el7.x86_64. 436 kB/s | 672 kB     00:01
(4/9): rh-php72-runtime-1-2.el7.x86_64.rpm      535 kB/s | 1.1 MB     00:02
(5/9): rh-php72-php-process-7.2.10-3.el7.x86_64 117 kB/s |  62 kB     00:00
(6/9): rh-php72-php-json-7.2.10-3.el7.x86_64.rp 121 kB/s |  54 kB     00:00
(7/9): rh-php72-php-xml-7.2.10-3.el7.x86_64.rpm 198 kB/s | 160 kB     00:00
(8/9): rh-php72-php-zip-7.2.10-3.el7.x86_64.rpm 160 kB/s |  90 kB     00:00
(9/9): rh-php72-php-cli-7.2.10-3.el7.x86_64.rpm 803 kB/s | 2.9 MB     00:03
Total                                           1.1 MB/s | 5.4 MB     00:04
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1
  Installing       : rh-php72-runtime-1-2.el7.x86_64                        1/9
  Running scriptlet: rh-php72-runtime-1-2.el7.x86_64                        1/9
  Installing       : rh-php72-php-json-7.2.10-3.el7.x86_64                  2/9
  Installing       : rh-php72-php-zip-7.2.10-3.el7.x86_64                   3/9
  Installing       : rh-php72-php-common-7.2.10-3.el7.x86_64                4/9
  Installing       : rh-php72-php-cli-7.2.10-3.el7.x86_64                   5/9
  Installing       : rh-php72-php-process-7.2.10-3.el7.x86_64               6/9
  Installing       : rh-php72-php-xml-7.2.10-3.el7.x86_64                   7/9
  Installing       : rh-php72-php-pear-1:1.10.5-1.el7.noarch                8/9
  Installing       : rh-php72-1-2.el7.x86_64                                9/9
  Verifying        : rh-php72-1-2.el7.x86_64                                1/9
  Verifying        : rh-php72-php-pear-1:1.10.5-1.el7.noarch                2/9
  Verifying        : rh-php72-runtime-1-2.el7.x86_64                        3/9
  Verifying        : rh-php72-php-common-7.2.10-3.el7.x86_64                4/9
  Verifying        : rh-php72-php-cli-7.2.10-3.el7.x86_64                   5/9
  Verifying        : rh-php72-php-process-7.2.10-3.el7.x86_64               6/9
  Verifying        : rh-php72-php-xml-7.2.10-3.el7.x86_64                   7/9
  Verifying        : rh-php72-php-json-7.2.10-3.el7.x86_64                  8/9
  Verifying        : rh-php72-php-zip-7.2.10-3.el7.x86_64                   9/9

  rh-php72.x86_64 1-2.el7
  rh-php72-php-cli.x86_64 7.2.10-3.el7
  rh-php72-php-common.x86_64 7.2.10-3.el7
  rh-php72-php-json.x86_64 7.2.10-3.el7
  rh-php72-php-pear.noarch 1:1.10.5-1.el7
  rh-php72-php-process.x86_64 7.2.10-3.el7
  rh-php72-php-xml.x86_64 7.2.10-3.el7
  rh-php72-php-zip.x86_64 7.2.10-3.el7
  rh-php72-runtime.x86_64 1-2.el7


Then # cd /opt/rh/rh-php72/ and run a couple scripts they leave for you:

# scl enable rh-php72 bash

# chmod +x enable && chmod +x register

# ./register && ./enable

Dir. /etc/opt
Dir. /etc/opt/rh
Dir. /etc/opt/rh/rh-php72
Dir. /etc/opt/rh/rh-php72/php.d
File /etc/opt/rh/rh-php72/php.d/20-json.ini
File /etc/opt/rh/rh-php72/php.d/20-zip.ini
File /etc/opt/rh/rh-php72/php.d/20-bz2.ini
File /etc/opt/rh/rh-php72/php.d/20-calendar.ini
File /etc/opt/rh/rh-php72/php.d/20-ctype.ini
File /etc/opt/rh/rh-php72/php.d/20-curl.ini
File /etc/opt/rh/rh-php72/php.d/20-exif.ini
File /etc/opt/rh/rh-php72/php.d/20-fileinfo.ini
File /etc/opt/rh/rh-php72/php.d/20-ftp.ini
File /etc/opt/rh/rh-php72/php.d/20-gettext.ini
File /etc/opt/rh/rh-php72/php.d/20-iconv.ini
File /etc/opt/rh/rh-php72/php.d/20-phar.ini
File /etc/opt/rh/rh-php72/php.d/20-sockets.ini
File /etc/opt/rh/rh-php72/php.d/20-tokenizer.ini
File /etc/opt/rh/rh-php72/php.d/20-posix.ini
File /etc/opt/rh/rh-php72/php.d/20-shmop.ini
File /etc/opt/rh/rh-php72/php.d/20-sysvmsg.ini
File /etc/opt/rh/rh-php72/php.d/20-sysvsem.ini
File /etc/opt/rh/rh-php72/php.d/20-sysvshm.ini
File /etc/opt/rh/rh-php72/php.d/20-dom.ini
File /etc/opt/rh/rh-php72/php.d/20-simplexml.ini
File /etc/opt/rh/rh-php72/php.d/20-xml.ini
File /etc/opt/rh/rh-php72/php.d/20-xmlwriter.ini
File /etc/opt/rh/rh-php72/php.d/20-xsl.ini
File /etc/opt/rh/rh-php72/php.d/30-wddx.ini
File /etc/opt/rh/rh-php72/php.d/30-xmlreader.ini
File /etc/opt/rh/rh-php72/php.ini
Dir. /etc/opt/rh/rh-php72/pear
File /etc/opt/rh/rh-php72/pear.conf
Dir. /usr/lib
Dir. /usr/lib/rpm
Dir. /usr/lib/rpm/macros.d
File /usr/lib/rpm/macros.d/macros.rh-php72-pear
Dir. /var/opt
Dir. /var/opt/rh
Dir. /var/opt/rh/rh-php72
Dir. /var/opt/rh/rh-php72/lib
Dir. /var/opt/rh/rh-php72/lib/php
Dir. /var/opt/rh/rh-php72/cache
Dir. /var/opt/rh/rh-php72/cache/php-pear
Dir. /var/opt/rh/rh-php72/www
Dir. /var/opt/rh/rh-php72/www/html

Check default version installed:

# php --version
PHP 7.2.10 (cli) (built: Nov 16 2018 15:24:33) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

success! Now to implement some of the apache scripts you have been talking about…

Edit: Doesn’t survive reboot, quick and dirty add to /etc/rc.d/rc.local should do it:

# echo 'scl enable devtoolset-7 bash 
scl enable rh-php72 bash' >> /etc/rc.d/rc.local

You could have some known issues with nethgui and php7x. Maybe you should enable php7x only for the virtualhost you need it

Is there a bug report you could point us towards, please?

No real gh issue raised, there will be a won’t fix

Ah, yes I just stumbled on the second one -

What’s the reason for not fixing, just curious?

good question, short answer sorry.

Efforts are going to replace nethgui with cockpit, please see in the forum the link for nethserver-cockpit

if you are interested to test in a VM

yum install nethserver-cockpit --enablerepo=nethserver-testing

then go to https://IP:9090

@AveryFreeman thanks to you there is a new rpm

yum install

the port used is 9002

# config show rh-php72-php-fpm

signal-event nethserver-rh-php72-php-fpm-update