PHP 5.6 CentOS 7

Can anyone provide any guidance on how to best update PHP 5.4.16 to 5.6 on a Linode CentOS 7. I know the distro does not support it, but I need it for some specific apps. Thanks!

13 Replies

Can anyone critique this process for installing PHP 5.6 on a Linode CentOS 7 Server?

https://zedt.eu/tech/linux/enabling-php … -centos-7/">https://zedt.eu/tech/linux/enabling-php-5-6-opcache-centos-7/

Will this work? Or will it cause damage?

I was looking for info on this myself. I read around, and found this set of upgrade instructions:

> To use the IUS packages in CentOS 7:

1. Install EPEL and IUS repositories:

yum –enablerepo=extras install epel-release

yum install https://centos7.iuscommunity.org/ius-release.rpm

2. Install yum-plugin-replace and replace the php packages with php56u packages:

yum install yum-plugin-replace

yum replace --replace-with php56u php

3. Restart any services which depend on php, such as httpd.

Note that this will install the current version of 5.6, which at the time of posting is 5.6.16, and that a "yum update" will keep the packages up to date in future.

I'm not a complete server neophyte, but this is something I've not done before (use a different repository), so I asked Linode support about it. They had this to say:

> It's hard to say if upgrading will break anything within your Linode as an infrastructure provider we do have our limitations as to what we can Support. But those steps you've listed look correct based my readings.

A subsequent question to them about "What's the official policy then" garnered this in reply:

> The official stance by CentOS's maintainers is to update to the latest version of CentOS 7 and then update PHP accordingly. However, if you want to keep the same version of CentOS then using a different repository for PHP updates should be fairly safe. If you need to, you can always uninstall PHP and install it from a different repository or package.

I've personally used Remi's repository for Enterprise Linux, which covers RHEL and CentOS:

https://rpms.remirepo.net/enterprise/7/

But I hear that IUS is also very reliable.

So at this point, I'm a bit confused as to what path to take. :)

I am starting the process of this myself, for a web application that no longer supports the base version (5.4) of PHP in CentOS 7. The most "official" way I have found is to use Software Collections. PHP 5.6 is included as a package. Once you have installed the centos-release-scl package, you will see a number of rh-php56* packages available through yum.

Keep in mind that these packages do not provide the built-in PHP module for Apache. To get that, you will need to install from the httpd24 Software Collection. I believe it should be possible to connect the base Apache in CentOS to PHP-FPM provided in rh-php56-php-fpm.

I wish it was easier to do this.

The real problem is with the apps that require PHP 5.6.

There is no real reason to require 5.6 over 5.4, since their differences are can be bridged with little work. I would understand an app that requires 7.1, which comes with major changes, but in all honesty, an app requiring 5.6 is just bad development. Even as a managerial decision, a good manager will want to support a long term release as supported by CentOS, a major corporate distro. Especially when some corporate environments will refuse to upgrade or use alternative repositories.

@IfThenElse:

The real problem is with the apps that require PHP 5.6.

There is no real reason to require 5.6 over 5.4, since their differences are can be bridged with little work. I would understand an app that requires 7.1, which comes with major changes, but in all honesty, an app requiring 5.6 is just bad development. Even as a managerial decision, a good manager will want to support a long term release as supported by CentOS, a major corporate distro. Especially when some corporate environments will refuse to upgrade or use alternative repositories.

PHP 5.6 was released almost 3 years ago, and PHP 5.5 was released 4 years ago. Even Debian Jessie has 5.6. Having reviewed their respective migration guides, there are several items which are not simple or are impossible to implement in code that supports PHP 5.4. A couple examples are argument unpacking (expanding an array to an argument list) and timing attack-safe string comparison (I'd love to see you implement that in PHP; your implementation will be wrong in subtle ways you won't realize).

You make the same assumption as my PCI DSS friends. You look at the version number and you think that is all that matters, when in fact that is not entirely the case. Redhat backports many improvements and fixes from newer versions into their official version, thus version PHP 5.4 in CentOS is not the same as the official PHP 5.4 that you download as a tar archive from php.net. I have the same argument with the PCI certification, when I try to explain that openssl 1.0.1e in CentOS has had a ton of backported fixes.

On the downside, the 10-year long term support by Redhat is not exactly 10 years. In the "small letters" (or in very clear a big letters if you find the correct page in their site), it is stated that those 10 years are split in 3 different parts. The first part is around 5 years and that is when you get most of the backports.

Anyway, for me there is no issue. Officially its 5.4 and if you want you can use Software Collections to support 5.6 or 7.

@IfThenElse:

You make the same assumption as my PCI DSS friends. You look at the version number and you think that is all that matters

No, I don't. I'm well aware of RedHat's bastardized creations from backporting specific features from newer releases. Just look at RHEL6's kernel; it reports it's 2.6.32, but the reality is that it's some frankenstein half 2.6.32 half 4.x kernel. And then there's when Linux 3.0 first released, and things like Mozilla's NSS build system threw errors because the kernel version didn't start with "2.6"; Fedora solved this by just changing the kernel version to 2.6.40, rather than fixing the check in NSS (among others).

Oh, I forgot to mention that there are two ways to get updated packages (for PHP and others), Software Collection was mentioned above, which installs packages in PARALLEL with the old ones, another way is to use IUS which overwrites the old packages and keeps them up to date with regular updates.

It is an important difference, since Software Collections will add fixes but will not offer regular upgrades of the same package, instead they release a new "collection". But it may work better for people who want to keep the old version of the packages around the system.

You can see a comparison of the two here: https://ius.io/IUSvsSCL/

I know it is a kludge. I prefer CentOS.

I needed to install Moodle. Their newest version will not install without PHP 5.6.

None of the CentOS solutions seemed adequate. I deployed a small linode with Debian 8 and use that for the Moodle instance. It provides the added advantage of distributing the workload between two linodes.

Probably not the best option but it works until Redhat catches up with the rest of the internet world. (That seems to happen every couple of years.)

I should probably just migrate away from CentOS????

For my Centmin Mod LEMP auto install which is CentOS only, I source compile PHP-FPM to support 5.5, 5.6, 7.0, 7.1 and 7.2 alpha and Nginx 1.13.x mainline with features supported newer than what Ubuntu/Debian side can provide :)

PHP 5.6.31 https://community.centminmod.com/thread … ble.12215/">https://community.centminmod.com/threads/php-5-6-31-is-available.12215/

But for multiple PHP-FPM version support I am working on, looking at Remi YUM repo for PHP 5.6, 7.0, 7.1 and 7.2 alpha to install side by side with my source compiled PHP-FPM.

Demo at https://community.centminmod.com/thread … iew.11900/">https://community.centminmod.com/threads/addons-php71-sh-multiple-php-fpm-versions-work-preview.11900/

and https://community.centminmod.com/thread … ha3.12211/">https://community.centminmod.com/threads/php-7-2-0-alpha3.12211/

so check it Remi at https://rpms.remirepo.net/ and https://blog.remirepo.net/post/2017/07/ … -and-7.1.7">https://blog.remirepo.net/post/2017/07/07/PHP-version-5.6.31-7.0.21-and-7.1.7

CentOS is a real server operating system, much better geared for an internet server, so I'm sticking to that. I tried Ubuntu, but it always feels like its struggling to hide that its actually a desktop system, I understand that kids these days prefer Ubuntu because its popular and comes preinstalled with laptops, but it just couldn't cut the cheese.

Remi is a good and reliable repo, highly suggested. His PHP packages will replace the old CentOS packages and we know that upgrades are frequent and kept up to date.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct