在 Ubuntu PHP 中启用 PCNTL - 测试失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14096130/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Enable PCNTL in Ubuntu PHP - test fails
提问by Folding Circles
I need help on How to: Enable PCNTL in Ubuntu PHP.
我需要关于如何:在 Ubuntu PHP 中启用 PCNTL 的帮助。
$ mkdir /tmp/phpsource
$ cd /tmp/phpsource
$ wget http://museum.php.net/php5/php-5.3.2.tar.gz
$ tar xvf php-5.3.2.tar.gz
$ cd php-5.3.2/ext/pcntl
$ phpize -bash: phpize: command not found
Everything went fine until I tried to run phpize! And then I get the error '-bash: phpize: command not found' ?? Any ideas?
一切都很顺利,直到我尝试运行 phpize!然后我收到错误'-bash: phpize: command not found' ?? 有任何想法吗?
UPDATE ran:
更新运行:
$ sudo apt-get update
and then ran:
然后跑:
$ sudo apt-get install php5-dev
With the help of Nick I managed to finish the procedure. But 'make test' fails???
在尼克的帮助下,我设法完成了程序。但是'make test'失败了???
$ phpize
$ ./configure
$ make
$ cp modules/pcntl.so /usr/lib/php5/20090626/
$ echo "extension=pcntl.so" > /etc/php5/conf.d/pcntl.ini
$ make test - FAILED!
HELP: I typed 'echo "extension=pcntl.so > /etc/php5/conf.d/pcntl.ini' instead of 'echo "extension=pcntl.so" > /etc/php5/conf.d/pcntl.ini' the first time I ran this. Is that BAD?
帮助:我输入'echo "extension=pcntl.so > /etc/php5/conf.d/pcntl.ini' 而不是'echo "extension=pcntl.so" > /etc/php5/conf.d/pcntl.ini '我第一次运行这个。那不好吗?
--------------------------------- Make TEst Error Messages --------------------------------------
--------------------------------- 制作测试错误信息 ------------- -------------------------
PHP Deprecated: Comments starting with '#' are deprecated in /tmp/phpsource/php-5.3.2/ext/pcntl/tmp-php.ini on line 1850 in Unknown on line 0
PHP Deprecated: Comments starting with '#' are deprecated in /tmp/phpsource/php-5.3.2/ext/pcntl/tmp-php.ini on line 1852 in Unknown on line 0
PHP Deprecated: Comments starting with '#' are deprecated in /tmp/phpsource/php-5.3.2/ext/pcntl/tmp-php.ini on line 1850 in Unknown on line 0
PHP Deprecated: Comments starting with '#' are deprecated in /tmp/phpsource/php-5.3.2/ext/pcntl/tmp-php.ini on line 1852 in Unknown on line 0
PHP Warning: Module 'pcntl' already loaded in Unknown on line 0
Warning: Module 'pcntl' already loaded in Unknown on line 0
PHP Deprecated: Comments starting with '#' are deprecated in /tmp/phpsource/php-5.3.2/ext/pcntl/tmp-php.ini on line 1850 in Unknown on line 0
PHP Deprecated: Comments starting with '#' are deprecated in /tmp/phpsource/php-5.3.2/ext/pcntl/tmp-php.ini on line 1852 in Unknown on line 0
PHP Warning: Module 'pcntl' already loaded in Unknown on line 0
Warning: Module 'pcntl' already loaded in Unknown on line 0
=====================================================================
PHP : /usr/bin/php
PHP_SAPI : cli
PHP_VERSION : 5.3.2-1ubuntu4.18
ZEND_VERSION: 2.3.0
PHP_OS : Linux - Linux lvps217-8-253-63.vps.webfusion.co.uk 2.6.32-042stab068.8 #1 SMP Fri Dec 7 17:06:14 MSK 2012 x86_64
INI actual : /tmp/phpsource/php-5.3.2/ext/pcntl/tmp-php.ini
More .INIs :
CWD : /tmp/phpsource/php-5.3.2/ext/pcntl
Extra dirs :
VALGRIND : Not used
=====================================================================
TIME START 2013-01-02 23:05:56
=====================================================================
FAIL Test pcntl wait functionality [tests/001.phpt]
FAIL pcntl: pcntl_sigprocmask(), pcntl_sigwaitinfo(), pcntl_sigtimedwait() [tests/002.phpt]
FAIL pcntl: SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK [tests/003.phpt]
FAIL Bug #47566 (return value of pcntl_wexitstatus()) [tests/bug47566.phpt]
FAIL pcntl_alarm() [tests/pcntl_alarm.phpt]
FAIL pcntl_exec() [tests/pcntl_exec.phpt]
FAIL pcntl_exec() 2 [tests/pcntl_exec_2.phpt]
FAIL pcntl_exec() 3 [tests/pcntl_exec_3.phpt]
FAIL Test function pcntl_fork() by calling it with its expected arguments [tests/pcntl_fork_basic.phpt]
FAIL Test function pcntl_fork() by testing the process isolation in the forking hierarchy father -> son -> grandson where father can not knows his grandson [tests/pcntl_fork_variation.phpt]
FAIL pcntl_signal() [tests/pcntl_signal.phpt]
FAIL pcnt_signal_dispatch() [tests/pcntl_signal_dispatch.phpt]
FAIL pcntl_wait() [tests/pcntl_wait.phpt]
FAIL Closures as a signal handler [tests/signal_closure_handler.phpt]
=====================================================================
TIME END 2013-01-02 23:05:59
=====================================================================
TEST RESULT SUMMARY
---------------------------------------------------------------------
Exts skipped : 0
Exts tested : 44
---------------------------------------------------------------------
Number of tests : 14 14
Tests skipped : 0 ( 0.0%) --------
Tests warned : 0 ( 0.0%) ( 0.0%)
Tests failed : 14 (100.0%) (100.0%)
Expected fail : 0 ( 0.0%) ( 0.0%)
Tests passed : 0 ( 0.0%) ( 0.0%)
---------------------------------------------------------------------
Time taken : 3 seconds
=====================================================================
=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Test pcntl wait functionality [tests/001.phpt]
pcntl: pcntl_sigprocmask(), pcntl_sigwaitinfo(), pcntl_sigtimedwait() [tests/002.phpt]
pcntl: SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK [tests/003.phpt]
Bug #47566 (return value of pcntl_wexitstatus()) [tests/bug47566.phpt]
pcntl_alarm() [tests/pcntl_alarm.phpt]
pcntl_exec() [tests/pcntl_exec.phpt]
pcntl_exec() 2 [tests/pcntl_exec_2.phpt]
pcntl_exec() 3 [tests/pcntl_exec_3.phpt]
Test function pcntl_fork() by calling it with its expected arguments [tests/pcntl_fork_basic.phpt]
Test function pcntl_fork() by testing the process isolation in the forking hierarchy father -> son -> grandson where father can not knows his grandson [tests/pcntl_fork_variation.phpt]
pcntl_signal() [tests/pcntl_signal.phpt]
pcnt_signal_dispatch() [tests/pcntl_signal_dispatch.phpt]
pcntl_wait() [tests/pcntl_wait.phpt]
Closures as a signal handler [tests/signal_closure_handler.phpt]
ANY ideas!?! Carl
有任何想法吗!?!卡尔
采纳答案by Censored P. Censored
Here's what I've found in Ubuntu 12.04:
这是我在 Ubuntu 12.04 中发现的内容:
Check your PHP.ini for the pnctl functions being disabled.
disable_functions = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriorityphpinfo reports the function is already loaded but it will not actually work without putting the pcntl.ini file into /etc/php5/conf.d.
检查您的 PHP.ini 是否禁用了 pnctl 功能。
disable_functions = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriorityphpinfo 报告该函数已经加载,但如果不将 pcntl.ini 文件放入 /etc/php5/conf.d,它实际上将无法工作。
Sadly, this causes 'module already loaded' errors every time PHP session cleanup cron in /etc/cron.d kicks off, but PCNTL won't function without both of these pieces in place, and so far I haven't found a good solution to disable the 'already loaded' error. Its messy, and ugly, and spams my root mail, and when I can find a solution, I will post it. I've only run into this problem in 12.04 so far.
遗憾的是,每次 /etc/cron.d 中的 PHP 会话清理 cron 启动时,这都会导致“模块已加载”错误,但是如果没有这两个部分,PCNTL 将无法运行,到目前为止我还没有找到一个好的禁用“已加载”错误的解决方案。它凌乱,丑陋,垃圾邮件我的根邮件,当我找到解决方案时,我会发布它。到目前为止,我只在 12.04 中遇到过这个问题。
UPDATE
更新
I hacked my /usr/lib/php5/maxlifetime script file to stop spamming with pnctl errors (PHP Warning: Module 'pcntl' already loaded in Unknown on line 0). Here are my edits - I specifically added in the 'E_DEPRECATED' line to quiet the messages.
我黑掉了我的 /usr/lib/php5/maxlifetime 脚本文件,以阻止带有 pnctl 错误的垃圾邮件(PHP 警告:Module 'pcntl' already loaded in Unknown on line 0)。这是我的编辑 - 我专门添加在“E_DEPRECATED”行中以消除消息。
Line 8:
第 8 行:
cur=$(php5 -c /etc/php5/${sapi}/php.ini -d "error_reporting='E_ALL & ~E_DEPRECATED'" -r 'print ini_get("session.gc_maxlifetime");' 2> /dev/null)
回答by rainysia
There is some steps like this: (my OS is debian7.2 xfce x86).
有一些这样的步骤:(我的操作系统是 debian7.2 xfce x86)。
1: i install pcntl like this
1:我像这样安装pcntl
#mkdir php
#cd php
#apt-get source php5
#cd php5-5.4.4/ext/pcntl
#phpize
#./configure
#make
#echo "extension=pcntl.so" > /etc/php5/mods-available/pcntl.ini
#ln -s /etc/php5/mods-available/pcntl.ini /etc/php5/conf.d/pcntl.ini
2: when is restart nginx or apache2, the php get one warning.
2:当重启nginx或apache2时,php得到一个警告。
"PHP Warning: Module ‘pcntl' already loaded in Unknown on line 0"
“PHP 警告:模块 'pcntl' 已在第 0 行的 Unknown 中加载”
3: so i
3:所以我
"rm -rf /etc/php5/mods-available/pcntl.ini and /etc/php5/conf.d/pcntl.ini"
“rm -rf /etc/php5/mods-available/pcntl.ini 和 /etc/php5/conf.d/pcntl.ini”
4: edit the "php.ini" file .
4:编辑“php.ini”文件。
a.apache2, it's in "/etc/php5/apache2/php.ini" b.cgi like nginx,it's in "/etc/php5/cgi/php.ini"
a.apache2, it's in "/etc/php5/apache2/php.ini" b.cgi like nginx,it's in "/etc/php5/cgi/php.ini"
make the
使
"disable_functions = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited..."
comments, add " ; " in front of "disable_functions".
restart your server and the warning gone.good luck.
重启你的服务器,警告消失了。祝你好运。
回答by KingCrunch
On my dev machine with ubuntu 12.10 (and earlier versions too) pcntl is/was already enabled.
在我的 ubuntu 12.10(以及更早版本)的开发机器上,pcntl 已经/已启用。
$ php -m | grep pcntl
pcntl
I guess thats the problem:
我想这就是问题所在:
PHP Warning: Module 'pcntl' already loaded in Unknown on line 0
PHP 警告:模块“pcntl”已加载到第 0 行的 Unknown 中
So just don't install it again.
所以只是不要再次安装它。
回答by Folding Circles
I NEEDED to restart the server! And now it works! Doh.. Thanks for everybodys input.
我需要重新启动服务器!现在它起作用了!Doh .. 感谢大家的投入。
回答by tigs001
In Ubuntu 15.04, the pcntl is installed in the php CLI, but disabled by default. To enable, edit /etc/php5/cli/php.ini and comment out the line:
在 Ubuntu 15.04 中,pcntl 安装在 php CLI 中,但默认情况下是禁用的。要启用,请编辑 /etc/php5/cli/php.ini 并注释掉该行:
disable_functions = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
If you want these enabled in apache2, then edit the file /etc/php5/apache2/php.ini and make the same change.
如果您希望在 apache2 中启用这些,请编辑文件 /etc/php5/apache2/php.ini 并进行相同的更改。
It may be advisable to only remove the functions you need to use, in order to preserve as much of the security restrictions as possible.
建议只删除您需要使用的功能,以尽可能多地保留安全限制。

