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