PHP编译配置安装pthread多线程 全过程

环境和版本:

系统:Centos7.2

mysql:mariadb-10

php包:php-5.6.36(http://au1.php.net/distributions/php-5.6.36.tar.gz)

pthread:v2.0.10 (https://github.com/krakjoe/pthreads/tree/v2.0.10)

github:https://github.com/krakjoe/pthreads

pthread v3对应PHP7,v2对应PHP5

 

pthread v3 版本开始只支持cli模式(命令行)运行脚本,其他运行方式pthread都会是失败的。

以下是作者说明:

SAPI Support

pthreads v3 is restricted to operating in CLI only: I have spent many years trying to explain that threads in a web server just don't make sense, after 1,111 commits to pthreads I have realised that, my advice is going unheeded.

So I'm promoting the advice to hard and fast fact: you can't use pthreads safely and sensibly anywhere but CLI.

Thanks for listening ;)

此文章我挑选了v2来配置!安装方法和步骤和v3都是相同的。

 

安装步骤:

### php

[root@sxm] # wget http://au1.php.net/distributions/php-5.6.36.tar.gz
[root@sxm] # tar -zxvf php-5.6.36.tar.gz
[root@sxm] # cd php-5.6.36
[root@sxm] # ./configure --prefix=/usr/local/php56 --with-config-file-path=/usr/local/php56/etc --with-config-file-scan-dir=/usr/local/php56/conf.d --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir=/usr/local/freetype --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local/curl --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --enable-fileinfo --enable-opcache --enable-intl --with-xsl  --enable-maintainer-zts

##### 上面配置参数 请修改成自己的mysql路径

[root@sxm] # make ZEND_EXTRA_LIBS='-liconv'

[root@sxm] # make install

#### 下面是配置php-fpm service方式启动

[root@sxm] # install -v -m755 sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm56

 

### pthread

[root@sxm] # wget https://codeload.github.com/krakjoe/pthreads/zip/v2.0.10

[root@sxm] # unzip v2.0.10

[root@sxm] # cd pthreads-2.0.10

[root@sxm] # /usr/local/php56/bin/phpize

[root@sxm] # ./configure --with-php-config=/usr/local/php56/bin/php-config

[root@sxm] # make && make install

 

在php.ini文件中加入:

extension=pthreads.so

启动php-fpm:

service php-fpm56 start

 

至此安装配置结束!如有问题可以留言

 

 

 

你可能感兴趣的:(PHP)