对于php,有很多种多过程的实现,这里就不说了,上面介绍一种多线程的形式。
php真正的多线程实现形式,通过装置php的扩大:pthread 扩大

原文链接:php 真正的多线程 pthread

装置步骤如下:

1.下载地址是这个:

https://github.com/krakjoe/pt...

然而这个下载的是 版本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