centos6.x/centos7.x安装php7

2018-05-02 11:51:22 查看 2017 回复 0

安装参考:https://webtatic.com/packages/php71

To install, first you must add the Webtatic EL yum repository information corresponding to your CentOS/RHEL version to yum:

(大概意思是:安装之前,首先需要把源添加到yum)

CentOS/RHEL 7.x:

yum install epel-release
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

CentOS/RHEL 6.x:

yum install epel-release
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm

源添加成功以后可以

yum list | grep php7

查看一下版本

上面显示 包含php7.0 与php7.1两个版本

然后yum安装php7与常用拓展

yum install php71w-cli php71w-common php71w-devel php71w-fpm php71w-gd php71w-mbstring php71w-mcrypt php71w-mysql  php71w-opcache php71w-pdo php71w-pdo_dblib php71w-pecl-memcached php71w-pecl-imagick php71w-pecl-mongodb php71w-pecl-redis php71w-xml


附加 centos7安装php7.4

PHP 7.4具有大量新功能,这个版本的RPM在remi-php74存储库中可用

一、添加EPEL和REMI存储库

运行以下命令以添加所需的存储库:

sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

sudo yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm

二、在CentOS 7上安装PHP 7.4版本

我们现在可以启用PHP 7.4 Remi存储库并在CentOS 7上安装PHP 7.4:

sudo yum -y install yum-utils

sudo yum-config-manager --enable remi-php74

在CentOS 7上安装PHP 7.4:

sudo yum update

sudo yum install php php-cli

接受安装提示,如下图所示:

fffffffff5

使用下一个命令安装其他软件包:

sudo yum install php-xxx

例如运行以下命令:

sudo yum install php  php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json

当前的PHP版本应为7.4版,如下所示:

$ php -v

PHP 7.4.0RC1 (cli) (built: Sep  3 2019 07:45:03) ( NTS )

Copyright (c) The PHP Group

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

如果要查看启用的模块,请运行:

$ php -m

至此,你已经在CentOS 7上成功安装了PHP 7.4