Install php extension pthreads to implement PHP multithreading

Source: Internet
Author: User
Tags php multithreading zts
Install php extension pthreads to implement PHP multithreading. the following two compilation methods are introduced:


1. compile pthreads extension on existing PHP

Note: The pthreads module needs to be dynamically loaded. before compiling php, -- enable-maintainer-zts must be enabled; otherwise, PHP needs to be re-compiled.

Pthreads source package: 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. recompile PHP and load 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 extract pthreads, move to php/ext/, and renamed pthreads;


Go to the php source code directory

./Buildconf -- force

./Configure -- help | grep thread

Whether -- enable-threads can be seen. if not, run the following command:


Rm-rf aclocal. m4

Rm-rf autom4te. cache/

./Buildconf -- force

Initialize the compilation configuration:

. /Configure -- prefix =/usr/local/php -- enable-opcache -- with-config-file-path =/etc -- with-mysql = mysqlnd -- with-mysqli = mysqlnd -- -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/with .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


Start php-fpm

/Etc/init. d/php-fpm start


Test and view the phpinfo output

Official documents: http://docs.php.net/manual/en/pthreads.installation.php#113019

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.