php 5 to 7

----------

systemctl restart httpd.service

php-pecl-mcrypt-1.0.3-1.el7.remi.7.4.x86_64.rpm

php-pear-1.10.10-4.el7.remi.noarch.rpm

php-common-7.4.3-1.el7.remi.x86_64.rpm

php-imap-7.4.3-1.el7.remi.x86_64.rpm

php-mbstring-7.4.3-1.el7.remi.x86_64.rpm

php-mysqlnd-7.4.3-1.el7.remi.x86_64.rpm

php-cli-7.4.3-1.el7.remi.x86_64.rpm

php-common-7.4.3-1.el7.remi.x86_64.rpm   

1

php -v

The output should match this:

1

2

3

PHP 5.4.16 (cli) (built: Apr 12 2018 19:02:01)

Copyright (c) 1997-2013 The PHP Group

Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

## Install PHP 7.4 

yum --enablerepo=remi-php74 install php

## Install PHP 7.3 

yum --enablerepo=remi-php73 install php

## Install PHP 7.2 

yum --enablerepo=remi-php72 install php

## Install PHP 7.1 

yum --enablerepo=remi-php71 install php

[root@demo ~]# php -v PHP 5.6.40 (cli) (built: Jan 12 2019 13:11:15)  Copyright (c) 1997-2016 The PHP GroupZend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

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

yum install yum-utils

yum-config-manager --enable remi-php74

yum --enablerepo=remi-php74 install php

Troubleshoot

If php upgrade process fails (no update/nothing happens) or you upgraded previously from 5.6 to 7.0/7.1/7.2 

then you need to run this commands to disable php 5.6/7.0/7.1/7.2 :

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

                ----------------

yum install epel-release

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

                                 Install PHP 7 on CentOS

# php -v

PHP 7.4.1 (cli) (built: Dec 17 2019 16:35:58) ( NTS )

Copyright (c) The PHP Group

Zend Engine v3.4.0, Copyright (c) Zend Technologies

                                Install PHP Modules

### For PHP 7.4

 yum --enablerepo=remi-php74 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt

  yum --enablerepo=remi-php74 install php-cli php-common phpw-bcmath php-dba php-devel php-embedded php-fpm php-gd php-imap php-interbase php-intl php-ldap php-mbstring php-mcrypt php-mysql php-odbc php-opcache php-pdo php-pdo_dblib php-pear php-process php-pspell php-recode php-tidy php-xml php-xmlrpc

yum -y upgrade php*

yum -y remove php

FOR PHP 7.0 EXECUTE:

yum-config-manager --enable remi-php70

yum-config-manager --enable remi-php71

yum-config-manager --enable remi-php72

yum-config-manager --enable remi-php73

yum-config-manager --enable remi-php74

Completely uninstall PHP under CentOS

View php version command:

#   php -v

The following command is to remove dirty

yum remove php

Because after using this command

#  php -v

You will still see version information. . . . .

It must be forcibly deleted. Here is a step by step method:

First, use the following command to view all php packages

#   rpm -qa | grep php

The tips are as follows:

# php-pdo-5.1.6-27.el5_5.3

# php-mysql-5.1.6-27.el5_5.3

# php-xml-5.1.6-27.el5_5.3

# php-cli-5.1.6 -27.el5_5.3

# php-common-5.1.6-27.el5_5.3

# php-gd-5.1.6-27.el5_5.3

Note that it is important to uninstall without dependencies first, otherwise the following situation will occur, and uninstallation will not be possible, but it does not matter, try the next one and delete all

rpm -e php-pdo-5.4.16-45.el7.x86_64

error: dependency detection failed:

    php-pdo (x86-64) = 5.4.16-45.el7 is (installed) php-mysql-5.4. 16-45.el7.x86_64 required

pdo is a dependency of mysql; common is a dependency of gd;

for example: # rpm -e php-pdo-5.1.6-27.el5_5.3

error: Failed dependencies:

        php-pdo is needed by (installed) php-mysql -5.1.6-27.el5_5.3.i386

So the correct uninstall sequence is:

# rpm -e php-mysql-5.1.6-27.el5_5.3 

# rpm -e php-pdo-5.1.6-27.el5_5.3 

# rpm -e php-xml-5.1.6-27.el5_5. 3 

# rpm -e php-cli-5.1.6-27.el5_5.3 

# rpm -e php-gd-5.1.6-27.el5_5.3 

# rpm -e php-common-5.1.6-27.el5_5 .3 

Reuse

# php -v

————————————————

版权声明:本文为CSDN博主「明世隐」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。

原文链接:https://blog.csdn.net/bernin/article/details/82634296

-------