php pthread 实例,php 真正的多线程 pthread

对于php,有很多种多进程的实现,这里就不说了,下面介绍一种多线程的方式。

php真正的多线程实现方式,通过安装php的扩展:pthread 扩展

安装步骤如下:

1.下载地址是这个:

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

我们需要使用2版本

fabe32c88af12fd52a4384629a4be315.png

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

97dc82b05421095677145190ef2e75cf.png

6f51af9b35cf31392f4e7bc9e180f69a.png

在下一页找到版本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

添加

重启php

我之前搞的一个用php多线程获取订单货运号的例子:

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值