简体   繁体   English

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

[英]php -v and php-fpm -v show different versions of 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 我在Mac上并使用自制软件安装php和nginx,我运行了以下显示成功的代码

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 当我运行Brew服务列表时,得到以下信息

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 但是,当尝试运行Wordpress网站时,我的nginx日志中出现以下错误

[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. 我已经用谷歌搜索了这个问题,看来这通常是nginx将请求传递给php-fpm的问题,我已经检查了正在运行每个服务的用户以确保它们匹配,因为我和我都以root身份进行了此操作徒劳无功。 When I check "brew services list" it shows php in orange which I understand to mean it has actually failed. 当我检查“ brew services list”时,它以橙色显示php,我理解这表示它实际上已失败。

I dug a bit further and it seems that if I run 'php -v' I get 我进一步挖掘了一点,看来如果我运行“ php -v”,我会得到

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

but if I run 'php-fpm -v' I get: 但是如果我运行'php-fpm -v'我得到:

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. 我相信这给我带来了一个问题,我用Google搜索了它,但没有任何确定的解决方法。

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! 提前致谢!

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"' 好的,我现在已经使php -vphp-fpm -v返回相同的php值,我通过运行brew doctor做到了这一点,它告诉我运行echo'export '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 因此,现在我正在运行相同的版本,并且可以在不使用lsof -i | grep php-fpm失败的情况下确认php-fpm正在运行lsof -i | grep php-fpm lsof -i | grep php-fpm I'm on to normal problems that people have installing php and nginx on their mac books! lsof -i | grep php-fpm我正在解决人们在Mac图书上安装php和nginx的正常问题! 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 :) 谢谢大家的时间和建议:)

For me, I have the following architecture after installing php (not with brew) but perhaps this will help anyway... 对我来说,在安装php之后(不与brew一起使用),我具有以下体系结构,但无论如何这可能会有所帮助...

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和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: 我有一个专门针对php-fpm7.2运行的服务,如下所示:

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). 使用php获得不同版本的事实是因为这是在命令行中运行的php版本-它的设置与使用fpm(从nginx传递)时会发生的设置不同。 I don't think the CLI php has much to do with your fpm versions. 我认为CLI php与您的fpm版本没有太大关系。 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. 可能是brew的php存储库仅是fpm 7.16的最新信息。我想我可能是从ppa安装PHP的,但我想不起来了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM