3
votes

There is apache2 web server on my ubuntu. I need to install pthreads, so I cloned a source code of php7 and pthreads from rep(copy to /ext/). I installed all libraries for php, then I ran

./buildconf 

and

./configure --prefix=/usr --with-config-file-path=/etc --enable-bcmath --enable-calendar --enable-cli --enable-debug --enable-dba --enable-exif --enable-ftp --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-pcntl --enable-shmop --enable-soap --enable-opcache --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --enable-zip --enable-maintainer-zts --with-freetype-dir=/usr/local/opt/freetype --with-openssl --with-gd --with-gettext=/usr/local/opt/gettext --with-iconv-dir=/usr --with-icu-dir=/usr --with-mhash --with-jpeg-dir=/usr/local/opt/jpeg --with-kerberos=/usr --with-libedit --with-mhash --with-png-dir=/usr/local/opt/libpng --with-zlib=/usr --with-apxs2=/usr/bin/apxs --libexecdir=/usr/local/php7/7.0.0/libexec --with-bz2=/usr --enable-fpm --with-fpm-user=_www --with-fpm-group=_www --with-curl --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-mcrypt --enable-pthreads.

It`s finished good and I executed 'make' and 'make install'. Then I executed next commands in console:

sudo a2dismod php5
sudo cp /etc/apache2/mods-available/php5.conf /etc/apache2/mods-enabled/php7.conf
sudo rm -rf /usr/bin/php && sudo ln -s /etc /usr/bin/php
sudo service apache2 restart

In this way I got apache2 with php7, but it does`t start and give logs for me:

PHP Fatal error: The apache2handler SAPI is not supported by pthreads in Unknown on line 0 PHP Fatal error: Unable to start pthreads module in Unknown on line 0 Unknown(0) : Fatal error - The apache2handler SAPI is not supported by pthreads Unknown(0) : Fatal error - Unable to start pthreads module

If I configure php7 without --enable-pthreads, it works. I executed phpinfo() and got result.

How can I solve this problem?

1

1 Answers

8
votes

pthreads v3 prohibits loading in anything but CLI.

It has never made sense to create threads in a web server context, in response to a client. Creating threads additional to those created by the server, destroys stability and scalability.

Creating multi-threaded applications inside of other multi-thread, multi-process applications, without any decent way of making either application properly aware and prepared for the other, is a terrible idea; It cannot work reliably and so is disabled.

You must reserve multi-threading for the command line, where it is safe and sensible.

Building pthreads shared (--enable-pthreads=shared), and loading it only in CLI will solve your problem.