首页 >后端开发 >php教程 >pthreads(四)php7只支持在cli模式下使用pthreads扩展

pthreads(四)php7只支持在cli模式下使用pthreads扩展

WBOY
WBOY原创
2016-06-20 12:33:392451浏览

1 ERROR!

用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

2 WHY?

 一直以为这个问题是可能是因为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


     

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn