1、下载pthreads的源码包
https://pecl.php.net/package/pthreads
如:pthreads-3.1.6.tgz
2、解压
> tar zxvf pthreads-3.1.6.tgz
> cd pthreads-3.1.6
3、通过phpize命令生成configure
> /data/nmp/php/bin/phpize
4、生成好后,运行configure
> ./configure --with-php-config=/data/nmp/php/bin/php-config
(如果出现error: pthreads requires ZTS, please re-compile PHP with ZTS enabled的错误,说明在编译php时没有加入--enable-maintainer-zts,所以只能重新编译php)
5、make && make install
> make
> make install
6、如果出现如下信息,说明成功
Installing shared extensions: /data/nmp/php/lib/php/extensions/no-debug-non-zts-20151012/
7、修改php.ini
extension_dir = "/data/nmp/php/lib/php/extensions/no-debug-non-zts-20151012/"
extension=pthreads.so
8、重启服务器,查看phpinfo()