关于 macos 下 PHP -v 和 PHP -fpm -v 版本不同的问题

2019-05-15 20:27:23 +08:00
 0clickjacking0

我使用了macos10.13系统,用phpbrew来管理多版本 php,系统自带的 php 版本是 7.1.16 ,我用 phpbrew 下载来 php5.6 的版本,然后我用命令phpbrew switch 5.6切换了 php 版本,然后在终端下输入命令php -v

输出结果为:

PHP 5.6.30 (cli) (built: May 14 2019 18:30:16)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

输入命令php-fpm -v

输出结果为:

PHP 7.1.16 (fpm-fcgi) (built: Mar 31 2018 03:00:16)
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

web 页面输出phpinfo()也是 7.1.16

系统自带的php-fpm位置在/usr/sbin,我尝试把我下载的 php-fpm5.6 的替换到这里,页面就 404

nginx 报错为:

2019/05/15 18:35:48 [error] 3125#0: *51 kevent() reported that connect() failed (61: Connection refused) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "127.0.0.1:82"
2019/05/15 18:35:48 [error] 3125#0: *51 open() "/usr/local/Cellar/nginx/1.15.12/html/50x.html" failed (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "127.0.0.1:82"
2019/05/15 18:35:48 [error] 3125#0: *51 kevent() reported that connect() failed (61: Connection refused) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "127.0.0.1:82"
2019/05/15 18:35:48 [error] 3125#0: *51 open() "/usr/local/Cellar/nginx/1.15.12/html/50x.html" failed (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "127.0.0.1:82"
ailed (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "127.0.0.1:82"
2019/05/15 18:48:03 [error] 3125#0: *64 kevent() reported that connect() failed (61: Connection refused) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "127.0.0.1:82"
2019/05/15 18:48:03 [error] 3125#0: *64 open() "/usr/local/Cellar/nginx/1.15.12/html/50x.html" failed (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "127.0.0.1:82"

html 解析的正常的,问题就出在 php-fpm,google 搜索两天也没解决,各位师傅可以帮我看看吗,我想让 php-fpm 变成 5.6 的

5265 次点击
所在节点    PHP
19 条回复
salamanderMH
2019-05-15 21:03:33 +08:00
用 docker 吧
GuangXiN
2019-05-15 21:08:26 +08:00
which php 看看程序在哪里
wxyoung
2019-05-15 21:08:43 +08:00
先 kill 掉本地的 php-fpm 进程

然后用 brew services start php@5.6 来启动 brew 安装的 5.6 版本
veike
2019-05-15 21:17:49 +08:00
安装 5.6 版本的 php-fpm 啊
0clickjacking0
2019-05-15 21:26:11 +08:00
@wxyoung 我用的是 phpbrew 安装的 php,不是用 brew 安装的 php
0clickjacking0
2019-05-15 21:29:05 +08:00
@GuangXiN which 就是在我的家目录下,因为我是用 phpbrew 安装的 5.6,而且 php -v 是 5.6 版本的
0clickjacking0
2019-05-15 21:29:41 +08:00
@veike 安装了,phpbrew 编译的时候我加了--fpm 的参数的
huanghaofu86
2019-05-15 21:40:56 +08:00
楼主,我也是搞 IOS 开发 ,可以加你扣吗我的是 2146 去掉 @ 274454
0clickjacking0
2019-05-15 21:48:28 +08:00
@huanghaofu86 哈哈哈,我不是搞 ios 开发的,mac 好用罢了
0clickjacking0
2019-05-15 21:49:49 +08:00
@salamanderMH 这是最后的办法吧,如果实在搞不好的话
torans
2019-05-15 21:56:25 +08:00
valet plus
Bardon
2019-05-15 22:21:46 +08:00
/path/to/php5-fpm -y /path/to/php5-fpm.conf -F 启动,没问题后再转到后台

不要直接替换二进制,默认配置文件格式都不太一样了,你 php5-fpm 都没起来,ps aux|grep php5 看下有无进程吧。
des
2019-05-15 23:14:00 +08:00
试试 brew link ?
andychen1
2019-05-16 08:59:52 +08:00
哈哈😄,我估计是这样:Mac 是出厂就装了 PHP 的,就是你那个低版本的;另外你可能自己人装了 7.x 的
jsjscool
2019-05-16 14:12:09 +08:00
又不是生产环境,用啥 php-fpm ? 直接 php -S localhost:8080 搞定
LittleLease
2019-05-25 14:27:04 +08:00
直接用 docker 就好了
GuangXiN
2019-05-25 18:11:59 +08:00
@jsjscool 单入口的框架需要用 rewrite,光有 php -S 不方便
ccc825
2020-02-06 02:24:52 +08:00
域名挂了,还好找到你的 gitpage 了。搞这个搞了一天头都大了 T。T
0clickjacking0
2020-05-11 17:50:37 +08:00
@ccc825 不好意思,xianyu123.me 域名太贵了,我没有续费,博客地址就是: https://0clickjacking0.github.io/

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/564480

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX