How to install php in centos7: 1. Install php yum source; 2. Clean up old php through "yum -y remove php*"; 3. Install php streamlined extension; 4. Set php-fpm to start automatically at boot. That’s it.
The operating environment of this article: centos7 system, PHP7.2 version, DELL G3 computer
How to install php in centos7?
Centos7 install PHP7.2
Suggested method
# 安装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
Install php yum source
# 方法一: 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
Clean up old php
yum -y remove php*
Check the php version that can be installed
yum list php*
Install php streamlined extension
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 starts automatically after booting
systemctl enable php-fpm
This installation method may cause yum info php and php - v The PHP versions displayed by the two commands are different
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to install php on centos 7. For more information, please follow other related articles on the PHP Chinese website!