yum安装
yum相当于是自动化安装,你不用管软件的依赖关系,在yum安装过程是帮你把软件的全部依赖关系帮你一键完成。而且现在Centos7的服务启动已经换成systemctl命令来控制了。通过yum安装会帮你自动注册服务,你可以通过systemctl start xxx.service启动服务,方便快捷。但是缺点是yum安装你没办法干预,安装的目录也是分散的。你可能要执行whereis或者find命令去查找yum安装的路径。有时候yum安装的软件版本比较低,比如centos7默认情况下系统给你安装的php版本为5.4版本,这时候你不得不去找其他的yum源,或者rpm包来安装最新版本的软件。
安装方式
1.安装源
yum install epel-release
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
2.安装YUM管理工具
yum install yum-utils
3.安装PHP
yum -y install php74-php-gd php74-php-pdo php74-php-mbstring php74-php-cli php74-php-fpm php74-php-mysqlnd
- 启动
systemctl start php74-php-fpm
如果启动不了有可能是当期版本的端口号和服务器的php版本号冲突,把php版本号改为9001就可以
运行并查看版本, 重启命令, 添加自动启动,链接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
#查看php版本
php -v
卸载 php7.4
yum remove php74-php*