我的 ubuntu 上有 apache2 网络服务器。我需要安装 pthreads,所以我从 rep(复制到/ext/)克隆了 php7 和 pthreads 的源代码。 我为 php 安装了所有库,然后运行
./buildconf
和
./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.
一切顺利,我执行了“make”和“make install”。 然后我在控制台中执行了下一个命令:
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
通过这种方式我得到了带有 php7 的 apache2,但它没有启动并为我提供日志:
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
如果我在不使用 --enable-pthreads 的情况下配置 php7,它就可以工作。我执行了 phpinfo() 并得到了结果。
我该如何解决这个问题?
最佳答案
pthreads v3 禁止在 CLI 以外的任何地方加载。
在 Web 服务器上下文中创建线程来响应客户端从来没有任何意义。在服务器创建的线程之外创建线程会破坏稳定性和可伸缩性。
在其他多线程、多进程应用程序内部创建多线程应用程序,而没有任何合适的方法让任何一个应用程序正确地感知另一个应用程序并为另一个应用程序做好准备,这是一个糟糕的主意;它无法可靠地工作,因此被禁用。
您必须为命令行保留多线程,这是安全和明智的。
构建共享的 pthreads (--enable-pthreads=shared),并仅在 CLI 中加载它可以解决您的问题。
关于php - Apache2,线程。 fatal error 。 pthreads 不支持 apache2handler SAPI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32795281/