Document toolboxDocument toolbox

(v1) PHP Upgrade RedHat/CentOS

NOTE: For an install these steps still apply, just skip any steps that remove or disable existing packages.

PHP 7.4 is not available from any repo on RedHat 6 or CentOS 6. The highest version it can be upgraded to is PHP 7.3.

For customers running PCR-360 Versions 2018.1 through 2020.2, PHP 7.2 is required.  

For customers running PCR-360 Versions 2020.3 through 2020.4, PHP 7.2 or PHP 7.4 may be installed.

For customers running PCR-360 Versions 2021.1 or later, PHP 7.4 is required

For customers running PCR-360 Versions 2022.1 or later, PHP 7.4 or PHP 8.1 may be installed

Preparation

Update the installed packages

# get rooted
sudo su

# apply the cream
yum -y update

# If you run into a GPG key issue with the percona repo (or another package), reinstall the repo it and try to update again
# Example
sudo yum install https://repo.percona.com/yum/percona-release-latest.noarch.rpm
yum -y update

STEP 1: Install the Repos

RHEL 8 / CentOS 8

# these are probably already installed
dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

RHEL 7 /  CentOS 7

# these are probably already installed
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm

# RHEL ONLY
subscription-manager repos --enable=rhel-7-server-optional-rpms

RHEL 6 / CentOS 6

# remove the old repo without php7.4
yum remove remi-release

# add the new repo with php7.4
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

# RHEL only
rhn-channel --add --channel=rhel-$(uname -i)-server-optional-6

STEP 2: Configure the New Repos

RHEL 8 or CentOS 8 :

Disable the previously installed PHP Version

# remove any prefixed installs
# yum remove php[VERSION_NUMBER]*
dnf remove php7*

# if not already installed
dnf install dnf-utils

# Use the line corresponding to the currently installed version
dnf module disable php:remi-5.6
dnf module disable php:remi-7.0
dnf module disable php:remi-7.1
dnf module disable php:remi-7.2
dnf module disable php:remi-7.3
dnf module disable php:remi-7.4

Reset PHP and enable the new version

dnf module reset php

# try to enable php from the RHEL repo first.
dnf module enable php:<version number>
# example
dnf module enable php:8.1

#if it's not working/available, try remi
dnf module enable php:remi-<version_number>
#example 
dnf module enable php:remi-8.1

RHEL 6, 7 or CentOS 6, 7 :

Disable the previously installed PHP Version

# remove any prefixed installs
# yum remove php[VERSION_NUMBER]*
yum remove php72*

# if not already installed
yum install yum-utils

# Use the line corresponding to the currently installed version
yum-config-manager --disable remi-php56
yum-config-manager --disable remi-php70
yum-config-manager --disable remi-php71
yum-config-manager --disable remi-php72
yum-config-manager --disable remi-php73

Enable the new PHP version

yum-config-manager --enable remi-php<version>
#exmaple
yum-config-manager --enable remi-php81

STEP 3: Upgrade PHP

RHEL 8 and Centos 8

To upgrade from previous php version :

# install required php modules
dnf -y install php php-process php-xml php-pecl-apcu php-gd php-intl php-mbstring php-pecl-mcrypt php-pdo php-soap php-pecl-zip

# MySql support
dnf -y install php-mysqlnd
 
# LDAP Support
dnf -y install php-ldap

# Oracle support
yum -y install php-oci8

# this should update all installed PHP modules as well
dnf -y update

RHEL6, 7 and Centos 6, 7

To upgrade from previous php version:

# install required php modules
yum -y install php php-process php-xml php-pecl-apcu php-gd php-intl php-mbstring php-pecl-mcrypt php-pdo php-soap php-pecl-zip

# MySql support
yum -y install php-mysqlnd
 
# LDAP Support
yum -y install php-ldap

# Oracle support
yum -y install php-oci8

# this should update all installed PHP modules as well
yum -y update

Update the PHP INI

vim /etc/php.ini

# Update each line as specified

# Set max memory to 1 Gb
memory_limit = 1024M
 
# Set the max file upload size to 10 Megabytes
upload_max_filesize = 10M
 
# This would need to be set to the timezone in which the Server is located
date.timezone = America/Detroit

STEP 4: Verify thcorrect version is Installed

# This may vary depending on version installed, Just need to make sure the intended version is installed
php -v

[root@server ~]# php -v
PHP 7.4.2 (cli) (built: Jan 21 2020 11:35:20) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.2, Copyright (c), by Zend Technologies

Step 5: Restart Apache and PHP-FPM

RHEL 8, 7 and Centos 8, 7

systemctl restart httpd;

# if applicable (usually only needed for RHEL)
systemctl restart php-fpm;

RHEL6 and Centos 6

service httpd restart

# if applicable (usually only needed for RHEL)
service php-fpm restart

Troubleshooting the Upgrade

Because external customer owned servers are not maintained by PCR and often vary in their installations, these instruction may not work exactly as written.
Based on customer experiences running the upgrade, here some issue that may occur and how to resolve them:

PHP Warning: Failed loading Zend extension 'ZendGuardLoader.so'

The Zend Guard Loader PHP Extension is no longer used by PCR-360 and does not need to be reinstalled after removal. The extension may be safely removed if it remains after removing the previous version of PHP. These file paths may vary depending on the installation.

# prevent php from trying to load the extension
rm /etc/php.d/ZendGuardLoader.ini

# remove the extension from the system
rm /usr/lib64/php/modules/ZendGuardLoader.so

"Service Unavailable" 503 - attempt to connect to Unix domain socket /var/run/php72.sock (php-fpm72) failed

This can apply to any version. The old php module settings should be removed when installing, but this is not the case with some installations. In this instance, the settings file may need to be updated or removed manually. These file paths may vary depending on the installation.

// remove the old PHP module default settings
rm /etc/httpd/conf.d/php<version>.conf
#example
rm /etc/httpd/conf.d/php74.conf

The error may also occur if a the previous PHP installation was using a proxy to connect to to Apache. In this case the virtual host may need to be manually updated. To do this, first open the appropriate virtual host file (These file paths may vary depending on the installation):

# test environment
vi /etc/httpd/conf.d/pcr360_test.conf

# production environment
vi /etc/httpd/conf.d/pcr360_prod.conf

Now look for and remove (or comment out) the following (or similar) lines. Then save the file and restart Apache. This line may appear multiple times if multiple virtual hosts are configured and may have more or longer parameters for the SetHandler method.

#<FilesMatch \.php$>
#    SetHandler proxy:fcgi://php-fpm74
#</FilesMatch>

CRON Jobs Not Running or Running with Errors

If PHP was configured to use multiple versions , the CRON jobs may have been set to use a non standard executable. In this case the old executable (ex. /usr/bin/php72) may no longer exist and needs to be updated to the standard executable 'php'.

#edit the crontab as root
crontab -e

# for example, change a line like this
* * * * * /usr/bin/php72 /var/www/pcr360/prod/cli/zfcli.php -a cron.events.process -e prod -n 19 -i /var/www/pcr360/configs/pcr360.ini 1>> /var/www/pcr360/prod/logs/cron.log 2>&1

# to this
* * * * * php /var/www/pcr360/prod/cli/zfcli.php -a cron.events.process -e prod -n 19 -i /var/www/pcr360/configs/pcr360.ini 1>> /var/www/pcr360/prod/logs/cron.log 2>&1

PHP Extensions 

The following is a list of the required PHP extensions. Some of these will be installed with the PHP core installation others can be installed with yum and a few may require the PHP Extension Community Library (PECL). Many of these will have required library dependencies that will need to be installed as well.

Use this command to check which modules are installed:

php -m

apc - Alternative PHP Cache
calendar - calendar functions
ctype - character type checking
curl - libcurl support for http communication
date - date functions
dom - Document Object Model functions
exif - Exchangeable image information
fileinfo - File information functions
filter - DAta filtering and validation
ftp - FTP connection support
gd - Image manipulation module
gettext - NLS API support
gmp - GNU Multiple Precision
hash - Hash Digest functions
iconv - character set conversion
intl - Internationalization functions
imagick - Image Processing
json - JavaScript Object Notation functions
ldap - LDAP protocol support
libxml - XML library dependency for other modules
mbstring - Multi Byte Character Encoding support
oci8 - Driver for Oracle database support Only required if using Oracle. Requires an Oracle client already installed
openssl - openssl library interface
pcntl - Process Control support
pcre - Perl Compatible Regular Expressions
PDO - PHP Data Objects library Only required if using MySQL
pdo_mysql - PDO Driver for MySQL database support Only required if using MySQL
Phar - PHP Archive library - need for some other modules
posix - File system access function
readline - GNU Readline library access
Reflection - Class inspection library
session - Session Handling interface
shmop - Shared Memory acccess
SimpleXML - XML Toolset
soap - SOAP Connection libaray
sockets - Low Level Socket Communication
SPL - Standard PHP Library extension
tokenizer - Zend Engine Tokenizer interface
wddx - Web Distributed Data Exchange
xml - XMl Parser
xmlreader - XML Reader
xmlwriter - XMl Writer
xsl - XLS Standards implementation
zip - Zip Archive interface
zlib - gzip Archive interface


No longer needed or deprecated

mcrypt - encryption library interface (deprecated with PHP 7.0+ and no longer required after PCR-360 2019.1 or later)

regex - Regular Expression support

mhash - Digest Checksums


Help Desk Portal - Email: help@pcr.com - Phone: 616.259.9242