Call to undefined function pcntl_fork() php-fpm nginx

偶尔善良 提交于 2019-12-05 05:03:50

The PCNTL extension is meant to be restricted to operating in CLI only; You cannot use it in other server environments (fpm, mod_php, etc).

What is supposed to happen is that extensions marked as "cli" only are meant to be statically linked into CLI binary, or allowed to load shared in CLI, and omitted from shared builds targeting other SAPIs (libphp7.so).

The autoconf (ext/pcntl/config.m4) file that configures PCNTL for PHP is supposed to instruct the build process to disallow the loading of PCNTL in other SAPIS, it so happens that 1) it's not very good and 2) this was not taken into account when FPM was merged into PHP: So that FPM ignores it and links with PCNTL source anyway (if the extension is enabled at compile time), and other SAPIs will allow you to load the library if it's shared because the DSO (shared library) itself does not enforce SAPI restriction. Neither of these things (FPM linking, and others loading) should be allowed, and it's a terrible idea to force an unsupported SAPI to load PCNTL.

When you fork a process, you create a copy-on-write clone of the process that called fork: Inside of Apache or FPM this means duplicated file (socket) handles which you cannot possibly gracefully manage in the child process (for you have no access to them from PHP).

The reason this is supposed to be restricted to CLI (and early CGI) is that these SAPIs use a single process model. While FPM is technically a CGI interface, it is certainly not single process, and so never will be a suitable environment for forking in user land.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!