时间:2021-07-01 10:21:17 帮助过:19人阅读
用php7了,编译之后安装好扩展,运行php-fpm的时候报错,在公司没有解决,回家在mac上复现这个问题:
[24-Mar-2016 23:06:50] NOTICE: PHP message: PHP Fatal error: The fpm-fcgi SAPI is not supported by pthreads in Unknown on line 0
Fatal error: The fpm-fcgi SAPI is not supported by pthreads in Unknown on line 0
[24-Mar-2016 23:06:50] NOTICE: PHP message: PHP Fatal error: Unable to start pthreads module in Unknown on line 0
Fatal error: Unable to start pthreads module in Unknown on line 0
一直以为这个问题是可能是因为php7不稳定导致的,后来看到百度上有人说php7只允许CLI模式下使用pthreads扩展,对此半信半疑,好吧,上github看看:
pthreads v3 is restricted to operating in CLI only: I have spent many years trying to explain that threads in a web server just don't make sense, after 1,111 commits to pthreads I have realised that, my advice is going unheeded.
So I'm promoting the advice to hard and fast fact: you can't use pthreads safely and sensibly anywhere but CLI.
Thanks for listening ;)
以上是作者的原话3 SOLVE:
CLI模式下,php会优先读取php-cli.ini,如果没找到会使用php.ini,SO:
【1】cp php.ini php-cli.ini // extension=/..(路径)../pthreads.so
【2】编辑原来的php.ini文件注释掉pthreads扩展 // ;extension=/..(路径)../pthreads.so
这样CLI模式下php-cli.ini生效,而php-fpm不会读php-cli.ini