PHP 5.6 under Enterprise Linux 7 using Software Collections
By default, Enterprise Linux 7 is shipped with Apache 2.4.6 and PHP 5.4. For some current web applications this is way too old as development of PHP 5.4 stalled in fall 2015.
During the product life cycle, Red Hat offers 10 to 13 years (Extended Support) maintenance for all packages being part of the distribution - including PHP. From a security perspective, still using an older PHP version is not critical as Red Hat still maintains these versions. The most web projects discontinue to support this old PHP version for technical reasons.
For this problem, Red Hat Software Collections (RHSCL) offers the possibility to install newer versions of programming languages, web servers, database servers and some other applications. Unlike the normal Red Hat Enterprise Linux software sources, these packages are only supported for a short range of 2 to 3 years and not the full product life cycle time (10-13 years). The reason for this limited support is that the software that is part of RHCSL gets updated very often - so it is not economic to offer long-term support. New RHCSL versions are released every 18 months, a detailed list of support cycles can be found on the Red Hat website. All packages - except node.js - that are part of RHCSL are supported for production workloads. Of course, there is also a list of all included software products in the internet:
- RHCSL 2.1: [click me!]
- RHCSL 2.0: [click me!]
- RHCSL 1.1: [click me!]
- RHCSL 1.0: [click me!]
Software installed from RHCSL are placed underneath /opt/rh
to avoid conflicts with already installed services It is possible to install multiple versions of a software without forcing conflicts.
Using the scl
command it is possible to set exceptions on a per application basis. As an example, it is possible to set a newer Python version for a particular application without changing the system-wide default:
1$ python -V
2Python 2.7.5
3
4$ scl enable python34 bash
5$ env|egrep -i "path|scl"
6X_SCLS=python34
7PATH=/opt/rh/python34/root/usr/bin:/usr/local/bin:/usr/bin:/usr/local/sbin/usr/sbin
8...
9
10$ python -V
11Python 3.4.2
PHP upgrade
On a Red Hat Enterprise Linux 7 system, the software source "Red Hat Software Collections (RHEL 7 Server)" needs to be added - e.g. using directly in the Red Hat Network or on a Red Hat Satellite system.
Afterwards, the required PHP 5.6 packages can be installed:
1# yum install rh-php56-{runtime,php{,-cli,-common}}
During the installation, an additional Apache web server version 2.4.12 will be installed - the distribution's default version cannot be usued along with the newer PHP version.
After the installation, installed software packages can be listed using the scl command:
1# scl -l
2httpd24
3rh-php56
If Apache was installed previously, it must be disabled and stopped before using the new web server:
1# systemctl disable httpd ; systemctl stop httpd
2# systemctl enable httpd24-httpd ; systemctl start httpd24-httpd
This is also just the right time to remove old Apache and PHP packages:
1# yum remove httpd{,-tools} php{,-*}
It is important that the document root changed from /var/www
to /opt/rh/httpd24/root/var/www
. If you're using a dedicated partition for these files, you might need to alter the /etc/fstab
file. If you're also using SELinux, it is a good idea to restore file contexts:
1# vi /etc/fstab
2# mount -a
3# restorecon -Rv /opt/rh/httpd24/root/var/www