安裝php擴充pthreads實現PHP多線程

來源:互聯網
上載者:User
下面介紹兩種編譯方式:


1、在已有的PHP上編譯pthreads擴充

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

pthreads源碼包下載地址:http://pecl.php.net/package/pthreads


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輸出

官方文檔:http://docs.php.net/manual/en/pthreads.installation.php#113019

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.