WordPress 5.2, PHP, and CentOS 7

At work I have to support a WordPress (WP) site. I don’t like WP, being another JavaScript fuster cluck. Recently WP was updated to version 5.2. No big deal, except that version 5.2 requires PHP 5.6.20 or newer, preferably PHP 7.2.

CentOS 7, because parent Red Hat policy does not update PHP versions, is locked at version 5.4.

Reading around the web finds the usual copypasta with almost nobody understanding what they are explaining. Many people recommend using a site called webtatic.com, maintained by somebody named Andy Thompson. Trustworthy? I haven’t a clue.

The next popular copypasta is for the “remi” site, maintained by Red Hat employee Remi Collet. The repository is primarily focused on PHP packages. I would say this repository is trustworthy.

Noteworthy though, is the SCL repository is the only third-party repo sanctioned by upstream Red Hat.

Using SCL is straightforward. Configuring the additional PHP packages is not. After much effort digging around the web looking for clues, I finally got everything working.

    yum install centos-release-scl
    yum install rh-php72 rh-php72-php rh-php72-php-fpm rh-php72-php-mysqlnd

Edit /etc/httpd/conf.d/php.conf:

    # 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>>

Now enable and put everything in motion.

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

Verify port 9000 is open.

The SCL package does not include a way to use the new PHP path on login. Add the following /etc/profile.d/rh-php72.sh script:

    #!/bin/bash
    source scl_source enable rh-php72

After logging in php -v should show the newer version.

Complex. Typical of Red Hat engineering. Why not make SCL like Debian Backports and just allow users to update the existing PHP packages and be done?

WP should be working with the new PHP. Update to WP 5.2.

Then find a better way to run a blog or web site and find a less complex distro.

Posted: Category: Usability Tagged: CentOS

Next: Remote Access Fun

Previous: CentOS 8