本文操作环境:centos7系统、PHP7.2版、DELL G3电脑
centos7怎么安装php?
Centos7安装PHP7.2
建议方法
# 安装EPEL yum存储库
yum install epel-release -y
# 安装Remi存储库
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
# 安装 PHP 7.3
yum --enablerepo=remi-php73 install php
# 安装 PHP 7.2
yum --enablerepo=remi-php72 install php
# 安装 PHP 7.1
yum --enablerepo=remi-php71 install php
安装php yum源
# 方法一:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
# 方法二:
yum install epel-release -y
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
清理 旧php
yum -y remove php*
查看可以安装的php版本
yum list php*
安装php精简拓展
yum -y install php72w php72w-cli php72w-fpm php72w-common php72w-devel
# 也可以安装 豪华版拓展
yum -y install php72w php72w-cli php72w-fpm php72w-common php72w-devel php72w-embedded php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml
php-fpm开机自启
systemctl enable php-fpm
这种安装方法 可能会出现 yum info php与 php -v 两条命令 显示的php版本不同