温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

centos通过yum安装php的教程

发布时间:2020-10-08 20:16:05 来源:脚本之家 阅读:196 作者:阿安安 栏目:服务器

先给大家介绍下centos通过yum安装php

1、添加php的yum软件仓库

sudo rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm

2、安装php相关软件,执行过程中全部选择yes即可

sudo yum install php71w.x86_64 php71w-cli.x86_64 php71w-common.x86_64 php71w-gd.x86_64 php71w-ldap.x86_64 php71w-mbstring.x86_64 php71w-mcrypt.x86_64 php71w-mysql.x86_64 php71w-pdo.x86_64

3、安装php71-fpm

sudo yum install php71w-fpm.x86_64

等待安装完成输入php -version查看php版本

ps:下面看下CentOS 7下Yum安装PHP7.2步骤

1、安装源

安装php72w,是需要配置额外的yum源地址的,否则会报错不能找到相关软件包。

php高版本的yum源地址,有两部分,其中一部分是epel-release,另外一部分来自webtatic。如果跳过epel-release的话,安装webtatic的时候,会有错误爆出。

所以,这里需要的命令是:

rpm -Uvh https://dl.Fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.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

2、清除历史版本

为了防止CentOS上面发生php冲突,所以,这个命令还是先执行一下更好些。

yum -y remove php*

3、安装扩展包

事实上,这里面的对应扩展库很多,这里大家一定要注意cli和fpm这两个包,而其它的相关包就看您需要了。

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

4、安装完成以后,启动服务

systemctl enable php-fpm.service

systemctl start php-fpm.service

5、安装成功

总结

以上所述是小编给大家介绍的centos通过yum安装php的教程,希望对大家有所帮助!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI