安裝php擴充套件pthreads實現PHP多執行緒

2021-09-04 02:42:53 字數 1755 閱讀 9575

下面介紹兩種編譯方式:

1、在已有的php上編譯pthreads擴充套件

注:需要動態載入pthreads模組,之前在編譯php時必須啟用--enable-maintainer-zts;否則需要重新編譯php。

tar xf pthreads-1.0.0.tgz 

cd pthreads-1.0.0

phpize

./configure  --enable-pthreads --with-php-config=/usr/local/php/bin/php-config

make && make install

2、重新編譯php,載入pthreads

tar xf php-5.5.8.tar.gz

tar xf pthreads-1.0.0.tgz

mv pthreads-1.0.0  php-5.5.8/ext/pthreads  將pthreads解壓,移動到php/ext/下,並改名為pthreads;

來到php原始碼目錄

./buildconf  --force

./configure --help | grep thread 

是否能看到--enable-threads,如果沒有則執行:

rm -rf aclocal.m4

rm -rf autom4te.cache/

./buildconf --force

初始化編譯配置:

./configure --prefix=/usr/local/php --enable-opcache --with-config-file-path=/etc --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-fpm --enable-pthreads --enable-fastcgi --enable-static --enable-inline-optimization --enable-sockets --enable-wddx --enable-zip --enable-calendar --enable-bcmath --enable-soap --with-zlib --with-xmlrpc --enable-mbstring --without-sqlite --with-curl --enable-ftp --with-mcrypt  --with-freetype-dir=/usr/local/freetype.2.1.10 --with-jpeg-dir=/usr/local/jpeg.6 --with-png-dir=/usr/local/libpng.1.2.50 --disable-ipv6 --disable-debug --with-openssl --enable-maintainer-zts --disable-safe-mode --disable-fileinfo

make && make install 

cp php.ini-production /etc/php.ini

install -v -m755 ./php-5.5.7/sapi/fpm/init.d.php-fpm  /etc/init.d/php-fpm

啟動php-fpm

/etc/init.d/php-fpm start

測試,檢視phpinfo輸出

官方文件:

安裝php擴充套件pthreads實現PHP多執行緒

下面介紹兩種編譯方式 1 在已有的php上編譯pthreads擴充套件 注 需要動態載入pthreads模組,之前在編譯php時必須啟用 enable maintainer zts 否則需要重新編譯php。tar xf pthreads 1.0.0.tgz cd pthreads 1.0.0 php...

wamp安裝pthreads擴充套件(PHP多執行緒)

這個時候我們已經把命令列執行模式的環境配置好了,如果你要以web瀏覽器方式執行的話,需要把pthreadvc2.dll複製到apache的bin目錄下,比如 wamp bin apache apache2.4.4 bin,然後修改這個目錄下的php.ini,新增extension php pthre...

wamp安裝pthreads擴充套件(PHP多執行緒)

首先,通過phpinfo 檢視其中的 thread safety 項,這個專案就是檢視是否是執行緒安全,如果是 enabled,一般來說應該是ts版,否則是nts版。這個時候我們已經把命令列執行模式的環境配置好了,如果你要以web瀏覽器方式執行的話,需要把pthreadvc2.dll複製到apach...