(Solved) Installing PHP 7.2 from SCL

Issues related to applications and software problems
Post Reply
upnort
Posts: 57
Joined: 2014/10/21 20:37:57

(Solved) Installing PHP 7.2 from SCL

Post by upnort » 2019/05/13 21:12:57

CentOS 7, fully updated.

For some years we've been running WordPress with no issues.

WordPress (WP) version 5.2 requires PHP 5.6.20 or newer and the recommendation is PHP 7.x.

I installed PHP 7.2 packages from SCL:

Code: Select all

yum install centos-release-scl
yum install rh-php72 rh-php72-php rh-php72-php-fpm rh-php72-php-mysqlnd
systemctl enable rh-php72-php-fpm.service
systemctl start rh-php72-php-fpm.service
scl enable rh-php72 bash
systemctl restart httpd
Port 9000 is open.

I added /etc/profile.d/rh-php72.sh script:

Code: Select all

#!/bin/bash
source scl_source enable rh-php72
When I SSH into the server php -v shows version 7.2.10.

So far so good. I can log in to WP. I was able to update WP to version 5.2. No error messages, everything looks good in the WP dashboard.

In a web browser I can view the top level of the WP pages. When I select a link on the WP site I see the following:

Code: Select all

Your server is running PHP version 5.4.16 but WordPress 5.2 requires at least 5.6.20.
This error indicates WP is not seeing the new PHP. Seems I need something like the profile.d script to let WP know about the new version.

A reboot did not help (which was needed because of recent glibc updates).

What do I need to get WP to see the new PHP?

Thanks. :)
Last edited by upnort on 2019/05/13 22:21:57, edited 1 time in total.

upnort
Posts: 57
Joined: 2014/10/21 20:37:57

Re: Installing PHP 7.2 from SCL

Post by upnort » 2019/05/13 22:20:11

I found the culprit. I had not modified /etc/httpd/conf.d/php.conf.

Here are the full steps:

Code: Select all

yum install centos-release-scl
yum install rh-php72 rh-php72-php rh-php72-php-fpm rh-php72-php-mysqlnd
Create /etc/httpd/conf.d/fpm.conf:

Code: Select all

# PHP scripts setup 
ProxyPassMatch ^/(.*.php)$ fcgi://127.0.0.1:9000/var/www/html
Alias / /var/www/html/
Edit /etc/httpd/conf.d/php.conf:

Code: Select all

# SetHandler application/x-httpd-php
# This is the default with php 5.4
#<FilesMatch \.php$>
#    SetHandler application/x-httpd-php
#</FilesMatch>

# This is the default for php7
<FilesMatch \.php$>
  SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>

Code: Select all

systemctl enable rh-php72-php-fpm.service
systemctl start rh-php72-php-fpm.service
scl enable rh-php72 bash
systemctl restart httpd

User avatar
remirepo
Posts: 327
Joined: 2014/09/21 09:07:12
Location: France
Contact:

Re: (Solved) Installing PHP 7.2 from SCL

Post by remirepo » 2019/05/14 04:24:05

You don't need both ProxyPass and SetHandler

See https://developers.redhat.com/blog/2017 ... tion-tips/
Remi's Repository - Forum - Blog

upnort
Posts: 57
Joined: 2014/10/21 20:37:57

Re: (Solved) Installing PHP 7.2 from SCL

Post by upnort » 2019/05/14 18:42:59

You don't need both ProxyPass and SetHandler
OK. Thanks. I know nothing about PHP. :( I commented out the /etc/httpd/conf.d/fpm.conf file and restarted httpd. Seems to be working just fine.

Post Reply