• ☁☁☁☁☁☁☁☁   ☁☁☁☁☁☁☁☁  

Centos7(Liunx)安装PHP7.4版本

yum安装:

yum相当于是自动化安装,你不用管软件的依赖关系,在yum安装过程是帮你把软件的全部依赖关系帮你一键完成。而且现在Centos7的服务启动已经换成systemctl命令来控制了。通过yum安装会帮你自动注册服务,你可以通过systemctl start xxx.service启动服务,方便快捷。但是缺点是yum安装你没办法干预,安装的目录也是分散的。你可能要执行whereis或者find命令去查找yum安装的路径。有时候yum安装的软件版本比较低,比如centos7默认情况下系统给你安装的php版本为5.4版本,这时候你不得不去找其他的yum源,或者rpm包来安装最新版本的软件。

这里选用remi的源来安装,首先添加源:

yum install epel-release
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

安装PHP

yum --enablerepo=remi install php74-php

安装你所需要php扩展模块

yum --enablerepo=remi install php74-php php74-php-gd php74-php-xml php74-php-sockets php74-php-session php74-php-snmp php74-php-mysql

 

注:扩展安装格式php74-php-扩展模块名,缺什么扩展只要按照格式安装相应模块即可

运行并查看版本, 重启命令, 添加自动启动,链接php文件

#运行并查看版本
php74 -v
#重启命令php-fpm
systemctl restart php74-php-fpm
#添加自动启动
systemctl enable php74-php-fpm
#查看php7.4的安装路径
whereis php
#链接php文件
ln -s /opt/remi/php74/root/usr/bin/php /usr/bin/php

 

配置文件的路径:

# The current PHP memory limit is below the recommended value of 512MB.
vi /etc/opt/remi/php74/php.ini
memory_limit = 512M

#如果你运行的是nginx而不是apache,修改
vi /etc/opt/remi/php74/php-fpm.d/www.conf
user = apache
group = apache
# Replace the values with
user = nginx
group = nginx

 

卸载 php7.4

yum remove php74-php*

 

来源:https://mefj.com.cn/lur2727.html

 

posted @ 2020-10-19 14:00  运维密码  阅读(14776)  评论(0编辑  收藏  举报