微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

php 真正的多线程 pthread

对于PHP,有很多种多进程的实现,这里就不说了,下面介绍一种多线程的方式。
PHP真正的多线程实现方式,通过安装PHP的扩展:pthread 扩展

原文链接PHP 真正的多线程 pthread

安装步骤如下:

1.下载地址是这个:

https://github.com/krakjoe/pthreads

但是这个下载的是 版本3 也就是PHP 7 才能用的

我们需要使用2版本

然后刷新的页面如下,拖到最底部

下一页找到版本2的

下载下来,这个v2 才是PHP5才可以使用的

 

 

下载下来,安装:

或者,您直接这样下载:

```
cd /tools
wget https://github.com/krakjoe/pthreads/archive/v2.0.10.zip
unzip v2.0.10.zip
cd pthreads-2.0.10
/usr/local/PHP/bin/PHPize
./configure --with-PHP-config=/usr/local/PHP/bin/PHP-config
make
make install
```
注意:您的PHP 在编译的时候需要开启 --enable-maintainer-zts,

```
./configure --prefix=/usr/local/PHP --disable-fileinfo --enable-fpm --with-config-file-path=/etc --with-config-file-scan-dir=/etc/PHP.d --with-openssl --with-zlib --with-curl --enable-ftp --with-gd --with-xmlrpc --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-native-ttf --enable-mbstring --with-mcrypt=/usr/local/libmcrypt --enable-zip --with-MysqL=/usr/local/MysqL --without-pear --enable-maintainer-zts
```


vim /etc/PHP.ini
添加
```
extension=pthreads.so
```

重启PHP
```
/etc/init.d/PHP-fpm restart
```

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐