Upgrade the version of PHP on CentOS 7 to 5.6.x / 7.0.x / 7.1.x / 7.2.x / 7.3.x

Introduction

The version of PHP that is installed as a standard on CentOS 7.X, as of 2017-12-30,5.4.16.

I am running the e portfolio system mahara on the CentOS 7 server that I am operating, but the recommended version of PHP has changed since PHP 5.5.X since 17.10.X released on 2017-10-30 .

Therefore, when running the latest version of mahara you can see that it is not possible to operate with the version of PHP provided as standard.

Therefore, I thought about to make the version of PHP of CentOS 7 server the latest 7.1.X.

However, I searched various sites and made them refer to, but since there were some hooked parts, it is shown here as memorandum.

==== 2018-12-13 ====

Version 7.2.x and 7.3.x are appended



Pre-Update Environment Overview

L): CentOS version:CentOS Linux release 7.4.1708 (Core)

A): Apache version:Server version: Apache/2.4.6 (CentOS)

M): MySQL version:mysql Ver 15.1 Distrib 5.5.56-MariaDB, for Linux (x86_64) using readline 5.1

P): PHP version:PHP 5.4.16 (cli)



Update procedure



Add repository

We add EPEL and REMI repositories to bring PHP from other places, not from standard repositories (References (1)).

【EPEL Repository】

Type the following command

# yum install epel-release

Or

# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

【REMI Repository】

Type the following command

# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm



Delete all current PHP

In order to upgrade PHP, it is necessary to put it in the end after all. For this reason, rather than upgrading and updating, it is close to reinstalling.

Incidentally,/etc/php.iniIf there is something that is specially set for PHP, etc., just in casecpIt is good to evacuate and back up with commands.

After backing up the configuration file etc, hit the following command

# yum remove php-*

With this, PHP died. . . .



Install new PHP

From here we will insert a newer version of PHP than the standard. In addition, since it is not something that should be up-to-date and the function has been changed, consider either 5.6, 7.0, or 7.1 and install it.

After deciding the version, type the following command and install it

【For PHP 5.6.x】

# yum install --disablerepo=* --enablerepo=remi,remi-php56 php

【For PHP 7.0.x】

# yum install --disablerepo=* --enablerepo=remi,remi-php70 php

【For PHP 7.1.x】

# yum install --disablerepo=* --enablerepo=remi,remi-php71 php

【For PHP 7.2.x】

# yum install --disablerepo=* --enablerepo=remi,remi-php72 php

【For PHP 7.3.x】

# yum install --disablerepo=* --enablerepo=remi,remi-php73 php

Incidentally,--disablerepo=*Is an option necessary to invalidate all repositories once and to retrieve PHP only from remi. With this, you can specify the version smoothly.

By the way, I got command without PHP 5.4.x by designation without this option. . . It seems that there is no loss with this option attached (References (2)).



Add PHP related packages (return to original PHP environment)

I installed the PHP main body in the above. From here, install the relevant package that you used with the previous PHP and restore it. Especially, there is no unusual work, but it is also good to do at the same time when putting the above PHP main body.

When you decide what to install in the relevant package, hit and install the following command

Example)php-mysqlndWhenphp-intlWhen you want to

【For PHP 5.6.x】

# yum install --disablerepo=* --enablerepo=remi,remi-php56 php-mysqlnd php-intl

【For PHP 7.0.x】

# yum install --disablerepo=* --enablerepo=remi,remi-php70 php-mysqlnd php-intl

【For PHP 7.1.x】

# yum install --disablerepo=* --enablerepo=remi,remi-php71 php-mysqlnd php-intl

【For PHP 7.2.x】

# yum install --disablerepo=* --enablerepo=remi,remi-php72 php-mysqlnd php-intl

【For PHP 7.3.x】

# yum install --disablerepo=* --enablerepo=remi,remi-php73 php-mysqlnd php-intl



Restore PHP settings

All the necessary parts are completed in the above. Finally restore PHP settings and finish.

# vi /etc/php.ini

Comment out necessary items and keep it.



in conclusion

PHP5.4.x
Upgrading from, after all, just put it in again. I felt it was hard to find a command for that.

Although I have made various other sites reference, I excerpted only the main one (the one who comes to the top of the search top hit). Thank you very much.

Leave a Reply