CentOS 7下的安装PHP7.4的YUM安装方法
admin2024-08-14 10:13:56Linux运维
#安装PHP7.4
安装php第三方官方yum源
yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
#安装yum-tools管理工具
yum -y install yum-utils
#启用PHP 7.4 Remi存储库
yum-config-manager --enable remi-php74
#安装php扩展服务包
rpm -e $(rpm -qa|grep php)
yum install php74-php php74-php-cli php74-php-common php74-php-devel php74-php-embedded php74-php-gd -y
yum install php74-php-mcrypt php74-php-mbstring php74-php-pdo php74-php-xml php74-php-fpm php74-php-mysqlnd -y
yum install php74-php-opcache php74-php-pecl-memcached php74-php-pecl-redis php74-php-pecl-mongodb -y
[root@web02 ~]# php74 -v PHP 7.4.21 (cli) (built: Jun 29 2021 15:17:15) ( NTS )
[root@web02 ~]# rpm -ql php74-php-fpm
/etc/logrotate.d/php74-php-fpm
/etc/opt/remi/php74/php-fpm.conf
/etc/opt/remi/php74/php-fpm.d
/etc/opt/remi/php74/php-fpm.d/www.conf
将web01的nginx配置文件导入到web02
[root@web02 ~]# scp -rp root@172.16.1.7:/etc/nginx /etc/
将web01的php配置文件导入到web02
#[root@web02 ~]# scp -rp root@172.16.1.7:/etc/php-fpm.d /etc/
[root@web02 etc]$rpm -ql php74-php-fpm
\/etc/logrotate.d/php74-php-fpm
/etc/opt/remi/php74/php-fpm.conf
/etc/opt/remi/php74/php-fpm.d
/etc/opt/remi/php74/php-fpm.d/www.conf
.....
配置php-fpm用户与Nginx的运行用户保持一致
[root@web01 ~]# sed -i '/^user/c user = www' /etc/opt/remi/php74/php-fpm.d/www.conf
[root@web01 ~]# sed -i '/^group/c group = www' /etc/opt/remi/php74/php-fpm.d/www.conf
[root@web01 blog]# egrep "^user|^group" /etc/opt/remi/php74/php-fpm.d/www.conf
user = www
group = www
systemctl start php74-php-fpm
systemctl enable php74-php-fpm