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 版本開始只支持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來配置!安裝方法和步驟都是相同的。


安裝步驟:

### 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


至此安裝配置結束!如有問題可以留言




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章