linux:安装php7.x

Posted Pam

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux:安装php7.x相关的知识,希望对你有一定的参考价值。

参考:链接

更新yum源

CentOS/RHEL 7.x:

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

CentOS/RHEL 6.x:

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm

安装php7.x

yum install php70w-fpm php70w php70w-mysql

检测

查看版本

php -v

页面测试

1、默认的Apache站点目录:/var/www/html/

创建一个index.php文件

检测

2、验证 LNMP 环境是否搭建成功

a、创建测试文件

echo "<?php phpinfo(); ?>" >> /usr/share/nginx/html/index.php

b、重启 Nginx 服务

systemctl restart nginx

c、测试

报错

Resolving Dependencies
--> Running transaction check
---> Package php70w.x86_64 0:7.0.20-1.w6 will be installed
--> Processing Dependency: php70w-common(x86-64) = 7.0.20-1.w6 for package: php70w-7.0.20-1.w6.x86_64
--> Processing Dependency: php70w-cli(x86-64) = 7.0.20-1.w6 for package: php70w-7.0.20-1.w6.x86_64
--> Processing Dependency: php70w-cli = 7.0.20-1.w6 for package: php70w-7.0.20-1.w6.x86_64
--> Processing Dependency: httpd-mmn = 20051115 for package: php70w-7.0.20-1.w6.x86_64
--> Running transaction check
---> Package php70w.x86_64 0:7.0.20-1.w6 will be installed
--> Processing Dependency: httpd-mmn = 20051115 for package: php70w-7.0.20-1.w6.x86_64
---> Package php70w-cli.x86_64 0:7.0.20-1.w6 will be installed
---> Package php70w-common.x86_64 0:7.0.20-1.w6 will be installed
--> Processing Dependency: libgmp.so.3()(64bit) for package: php70w-common-7.0.20-1.w6.x86_64
--> Finished Dependency Resolution
Error: Package: php70w-common-7.0.20-1.w6.x86_64 (webtatic)
Requires: libgmp.so.3()(64bit)
Error: Package: php70w-7.0.20-1.w6.x86_64 (webtatic)
Requires: httpd-mmn = 20051115
Installed: httpd-2.4.6-45.el7.centos.4.x86_64 (@updates)
httpd-mmn = 20120211
httpd-mmn = 20120211x8664
httpd-mmn = 20120211-x86-64
Available: httpd-2.4.6-45.el7.centos.x86_64 (base)
httpd-mmn = 20120211x8664
httpd-mmn = 20120211-x86-64
httpd-mmn = 20120211
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest

方法:

yum clean all  //清除缓存

再次执行!

设置开机自启动

chkconfig --add php-fpm
chkconfig php-fpm on

以上是关于linux:安装php7.x的主要内容,如果未能解决你的问题,请参考以下文章

centos8 测地卸载php5.6 与卸载php7

PHP7.X连接SQLSERVER数据库(CENTOS7)

PHP7.X连接SQLSERVER数据库(CENTOS7)

PHP7.X连接SQLSERVER数据库(CENTOS7)

[linux][c/c++]代码片段01

[linux][c/c++]代码片段02