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

我一整晚都在苦苦挣扎,无法找到解决问题的答案! </ p>

我在Mac上并使用自制软件来安装php和nginx,我运行以下显示为成功的</ p>

  brew install  php 
brew install nginx
</ code> </ pre>

到目前为止没有任何问题我可以启动这两项服务</ p>

  brew services start nginx

brew服务启动nginx
</ code> </ pre>

当我运行brew服务列表时,我得到以下内容</ p>

  nginx启动我/  Users / me / Library / LaunchAgents / homebrew.mxcl.nginx.plist 
php启动了我/Users/me/Library/LaunchAgents/homebrew.mxcl.php.plist
</ pre>

  [error] 26099#0:* 1 kevent()报告connect() 连接到上游时失败(61:连接拒绝),客户端:127.0.0.1,服务器:localhost,请求:“GET / HTTP / 1.1”,上游:“fastcgi://127.0.0.1:9000”,主机:“localhost  :8080“
</ code> </ pre>

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

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

  PHP 7.2.9(cli  )(建于:2018年8月23日02:08:27)(NTS)
</ code> </ pre>

但如果我运行'php-fpm -v'我得到:</ p >

  PHP 7.1.16(fpm-fcgi)(内置:2018年3月31日03:00:16)
</ code> </ pre>

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

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

  $ which php 
/ usr / local / bin / php
$ which php -fpm
/ usr / sbin / php-fpm
</ code> </ pre>

有没有人有任何想法如何解决这个问题? </ p>

提前致谢! </ p>
</ div>

展开原文

原文

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: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", 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
/usr/local/bin/php
$which php-fpm
/usr/sbin/php-fpm

Does anyone have any ideas how I can resolve this?

Thanks in advance!

dongzhang6544
dongzhang6544 公平,我只是好奇,因为生产可能不会是MacOS。完全有效学习在Mac上设置它。我很抱歉...
大约 2 年之前 回复
dongqi6964
dongqi6964 感谢所有的帮助到目前为止@amurrell我不想使用docker,因为我不太了解它并且不喜欢尝试一次学习很多东西!我已经找到了自制软件安装php-fpm/usr/local/Cellar/php/7.2.9_2/sbin/php-fpm的地方所以我想我现在的问题是如何将php-fpm命令绑定到此位置而不是标准的一个?
大约 2 年之前 回复
douhuanbai6729
douhuanbai6729 请停止要求人们使用docker。这个问题完全合法,完全一样,你没有讨论它的背景。
大约 2 年之前 回复
duanpa2143
duanpa2143 也许在文档根目录中创建一个调用phpinfo()的PHP页面,看看nginx如何看待你的PHP设置。
大约 2 年之前 回复
dongmei3869
dongmei3869 只是FYI,/usr/local/bin是自制软件安装的,而/usr/sbin/php-fm是Apple提供的macOS。
大约 2 年之前 回复
dongtu4559
dongtu4559 你需要在macos上安装它吗?这是为了本地发展吗?为什么不使用docker?
大约 2 年之前 回复

2个回答



好的我现在已经有了 php -v </ code>和 php-fpm -v </ 代码>返回相同的php值,我通过运行 brew doctor </ code>来完成它,告诉我运行echo 'export PATH =“/ usr / local / sbin /:$ PATH”'< / code> </ p>

现在我已经运行了相同的版本并且可以确认php-fpm正在运行而不会失败使用 lsof -i | grep php-fpm </ code>我正常问题是人们在他们的mac书上安装了php和nginx! 因此我今晚可以轻松地知道我稍微接近目标了!</ p>

我现在还有以下</ p>

  $ php  -fpm 
/ usr / local / sbin / php-fpm
$ php php
/ usr / local / bin / php
</ code> </ pre>

谢谢大家 你的时间和建议:) </ p>
</ div>

展开原文

原文

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
/usr/local/sbin/php-fpm
$ which php
/usr/local/bin/php

Thank you everyone for your time and suggestions :)



对我来说,在安装php之后我有以下架构(不是brew),但也许这会有所帮助...... </ h3 >

  ls /etc/php/
5.6 7.0 7.1 7.2
</ code> </ pre>

我可以使用以下命令 输入php和tab:</ h3>

  php php-config php-config7.2 php-fpm7.2 php7.2 phpdismod phpenmod phpize phpize7.2 phpquery 
</ code> < / pre>

我有一个专门为 php-fpm7.2 </ code>运行的服务,如下所示:</ h2>

  sudo service php7  .2-fpm状态

  • php-fpm7.2正在运行
    root @ xxx:〜#sudo service php5.6-fpm status
    php5.6-fpm:unrecognized service
    root @ xxx:〜#sudo service php7。 1-fpm状态
    php7.1-fpm:无法识别的服务
    </ code> </ pre>


    您使用 php获得不同版本的事实 </ code>是因为这是在命令行中运行的php版本 - 它具有不同的设置 当你使用fpm(从nginx传递)时会发生什么。 我不认为CLI php与您的fpm版本有很大关系。 可能是brew的php存储库只是fpm 7.16的最新版本。我想我可能正在从ppa安装我的PHP但我不记得我的头脑。</ p>
    </ div>

展开原文

原文

For me, I have the following architecture after installing php (not with brew) but perhaps this will help anyway...

ls /etc/php/
5.6  7.0  7.1  7.2

and I have the following commands available if I type php and tab:

php            php-config     php-config7.2  php-fpm7.2     php7.2         phpdismod      phpenmod       phpize         phpize7.2      phpquery

I have a service running specifically for php-fpm7.2 as seen here:

sudo service php7.2-fpm status
 * php-fpm7.2 is running
root@xxx:~# sudo service php5.6-fpm status
php5.6-fpm: unrecognized service
root@xxx:~# sudo service php7.1-fpm status
php7.1-fpm: unrecognized service

The fact you are getting a different version with php is because that is the version of php that runs in the command line - and it has different settings than what will happen when you use fpm (passed through from nginx). I don't think the CLI php has much to do with your fpm versions. It could be that brew's repositories for php are only up to date for fpm 7.16.. I think I might be installing my PHP from a ppa but I cannot recall off the top of my head.

dpw63348
dpw63348 这看起来可能是我唯一的选择,因为另一个夜晚已经失去了试图让它工作,我在Mac上不是很好,所以道歉,如果这是一个简单的问题,但我如何设置服务? (我确实谷歌很快,但没有走得太远)
大约 2 年之前 回复
duandao2306
duandao2306 你可以尝试brew install php@7.2 - 但我不确定,因为我不使用mac ...
大约 2 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐