问题
I installed with success on Window 7 Enterprise the following:
httpd-2.4.25-win64-VC14
php-7.1.1-Win32-VC14-x64 (Thread Safe (2017-Jan-18 21:06:35))
php_pthreads-3.1.6-7.0-ts-vc14-x64 from http://windows.php.net/downloads/pecl/releases/pthreads/3.1.6/
The phpinfo page looks well and Thread Safety = enabled.
I followed all instructons on README.md file of php_pthreads-3.1.6-7.0-ts-vc14-x64
package.
However when I'm executing "php -m" I got this error:
PHP Warning: PHP Startup: pthreads: Unable to initialize module
Module compiled with module API=20151012
PHP compiled with module API=20160303
These options need to match
in Unknown on line 0
Warning: PHP Startup: pthreads: Unable to initialize module
Module compiled with module API=20151012
PHP compiled with module API=20160303
These options need to match
in Unknown on line 0
[PHP Modules]
bcmath
calendar
Core
ctype
date
... I have used threads before with PHP 5.4.33 but I decided to upgrade to PHP7 to have support for tlsv1.1 and tlsv1.2
回答1:
The reason for the error is that pthread dll is not compatible with the installed php version.
According to github issue discussion the last release php_pthreads-3.1.6-7.0-ts-vc14-x64 will not support php 7.0 or 7.1 on windows because of ZTS is broken on thease versions.
So if you are on windows, and want to work with pthread.. you have to degrade to PHP 5.6 or wait to PHP 7.2 and next release of php_pthreads.
Another option is to use this beta version of php_pthreads: https://github.com/SirSnyder/pthreads/releases/tag/v3.1.7-beta.1
来源:https://stackoverflow.com/questions/41751202/php7-startup-pthreads-unable-to-initialize-module-pthreads-in-windows-7