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