2018-09-03 21:26
浏览 703

php -v和php-fpm -v显示不同版本的php

I've been struggling with this all night and can't find an answer that fixes it!

I'm on a mac and using homebrew to install php and nginx, I ran the following which show as successful

brew install php
brew install nginx

no problems so far and I can start both services

brew services start nginx
brew services start nginx

when I run brew services list I get the following

nginx started me /Users/me/Library/LaunchAgents/homebrew.mxcl.nginx.plist
php   started me /Users/me/Library/LaunchAgents/homebrew.mxcl.php.plist

however when trying to run a Wordpress site I get the following error in my nginx log

[error] 26099#0: *1 kevent() reported that connect() failed (61: Connection refused) while connecting to upstream, client:, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://", host: "localhost:8080"

I have googled the problem and it seems that it's normally a problem with nginx passing a request to php-fpm, I have checked the user that is running each service to make sure they match, I have done it as both me and both root to no avail. When I check "brew services list" it shows php in orange which I understand to mean it has actually failed.

I dug a bit further and it seems that if I run 'php -v' I get

PHP 7.2.9 (cli) (built: Aug 23 2018 02:08:27) ( NTS )

but if I run 'php-fpm -v' I get:

PHP 7.1.16 (fpm-fcgi) (built: Mar 31 2018 03:00:16)

I believe this is causing me a problem, I have googled it but haven't got any definitive fixes.

Here is another oddity with it:

$which php
$which php-fpm

Does anyone have any ideas how I can resolve this?

Thanks in advance!

图片转代码服务由CSDN问答提供 功能建议



  brew install  php 
brew install nginx 


  brew services start nginx  


  nginx启动我/  Users / me / Library / LaunchAgents / homebrew.mxcl.nginx.plist 
  [error] 26099#0:* 1 kevent()报告connect() 连接到上游时失败(61:连接拒绝),客户端:,服务器:localhost,请求:“GET / HTTP / 1.1”,上游:“fastcgi://”,主机:“localhost  :8080“

我用Google搜索了问题,似乎这通常是一个问题 使用nginx向php-fpm发送请求的em,我已经检查了运行每个服务的用户以确保它们匹配,我已经完成了它,因为我和两个root都无济于事。 当我检查“brew services list”时 它显示了橙色的PHP,我理解这意味着它实际上已经失败了。

我进一步挖了一下似乎如果我运行'php -v'我得到

  PHP 7.2.9(cli  )(建于:2018年8月23日02:08:27)(NTS)

但如果我运行'php-fpm -v'我得到:

  PHP 7.1.16(fpm-fcgi)(内置:2018年3月31日03:00:16)

I 相信这会给我带来一个问题,我用谷歌搜索了它,但没有得到任何确定的修复。

这是另一个奇怪之处:<​​/ p>

  $ which php 
 / usr / local / bin / php 
 $ which php  -fpm 
 / usr / sbin / php-fpm 



  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

  • doupai1876 2018-09-04 22:26

    Okay I've now got both php -v and php-fpm -v returning the same value of php and i did it by running brew doctor which told me to run echo 'export PATH="/usr/local/sbin/:$PATH"'

    so now that I have the same versions running and can confirm that php-fpm is running without failing using lsof -i | grep php-fpm I'm on to normal problems that people have installing php and nginx on their mac books! So I can rest easy tonight knowing that I am slightly closer to my goal!

    I also now have the following

    $ which php-fpm
    $ which php

    Thank you everyone for your time and suggestions :)

    解决 无用
    打赏 举报

相关推荐 更多相似问题