首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >出于安全原因,pcntl无法在Ubuntu上运行

出于安全原因,pcntl无法在Ubuntu上运行
EN

Stack Overflow用户
提问于 2013-04-28 20:28:06
回答 2查看 21.4K关注 0票数 23

我已经使用this文章在我的PHP5.4.6上安装了pcntl,它运行在Ubuntu32位12.10上。

它一点也不顺利,因为在编译之后,当运行make test时,我得到了以下错误。每次我尝试派生一个子进程时,都会收到一个警告,上面写着:

警告:出于安全原因,已在第8行的/var/www/mydev/dev/mailServiceTest.php中禁用了pcntl_fork()

我在网上到处寻找解决方案,但不幸的是,我在其他任何地方都没有找到任何关于这个问题的提及。

代码语言:javascript
复制
    Build complete.
Don't forget to run 'make test'.
PHP Warning:  Module 'pcntl' already loaded in Unknown on line 0
PHP Warning:  Module 'pcntl' already loaded in Unknown on line 0

=====================================================================
PHP         : /usr/bin/php 
Warning: Module 'pcntl' already loaded in Unknown on line 0

PHP_SAPI    : cli
PHP_VERSION : 5.4.6-1ubuntu1.2
ZEND_VERSION: 2.4.0
PHP_OS      : Linux - Linux oleg-Lenovo-G580 3.5.0-26-generic #42-Ubuntu SMP Fri Mar 8 23:20:06 UTC 2013 i686
INI actual  : /php/php-5.4.6/ext/pcntl/tmp-php.ini
More .INIs  :  
CWD         : /php/php-5.4.6/ext/pcntl
Extra dirs  : 
VALGRIND    : Not used
=====================================================================
TIME START 2013-04-28 12:11:03
=====================================================================
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 Test pcntl_get_last_error() [tests/pcntl_get_last_error.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-04-28 12:11:07

=====================================================================
TEST RESULT SUMMARY
---------------------------------------------------------------------
Exts skipped    :    0
Exts tested     :   44
---------------------------------------------------------------------

Number of tests :   15                15
Tests skipped   :    0 (  0.0%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :   15 (100.0%) (100.0%)
Expected fail   :    0 (  0.0%) (  0.0%)
Tests passed    :    0 (  0.0%) (  0.0%)
---------------------------------------------------------------------
Time taken      :    4 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]
Test pcntl_get_last_error() [tests/pcntl_get_last_error.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]
=====================================================================

You may have found a problem in PHP.
This report can be automatically sent to the PHP QA team at
http://qa.php.net/reports and http://news.php.net/php.qa.reports
This gives us a better understanding of PHP's behavior.
If you don't want to send the report immediately you can choose
option "s" to save it.  You can then email it to qa-reports@lists.php.net later.
Do you want to send this report now? [Yns]: y

Please enter your email address.
(Your address will be mangled so that it will not go out on any
mailinglist in plain text): oleg.tt@gmail.com 

Posting to http://qa.php.net/buildtest-process.php

Thank you for helping to make PHP better.
oleg@oleg-Lenovo-G580:/php/php-5.4.6/ext/pcntl$ version

当输入以下命令时,似乎PHP确实已经安装,尽管PHP解释器在我安装此扩展之前根本无法识别该功能:

代码语言:javascript
复制
oleg@oleg-Lenovo-G580:/php/php-5.4.6/ext/pcntl$ php -m | grep pcntl
PHP Warning:  Module 'pcntl' already loaded in Unknown on line 0
pcntl

如何配置此功能才能正常工作?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-04-28 20:36:03

sudo gedit

代码语言:javascript
复制
sudo gedit /etc/php5/cli/php.ini

或者\和

sudo gedit /etc/php5/apache2/php.ini查找:

代码语言:javascript
复制
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

将其注释掉:

代码语言:javascript
复制
;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
票数 52
EN

Stack Overflow用户

发布于 2014-04-16 03:15:13

我也有这个问题。Ubuntu在/usr/share/php5中附带了一些示例PHP配置文件:php.ini-production是Apache web服务器PHP配置(/etc/php5/apache2/php.ini)的模板,它禁用了pcntl_fork和其他功能。php.ini-production.cli是用于从命令行(/etc/php5/cli/php.ini)运行的模板,它不会禁用任何功能。但不知何故,我的/etc/php5/cli/php.ini是Apache配置的副本,它禁用了这些功能。

我不知道这是怎么发生的。我用Ubuntu 12.04安装了我的LAMP堆栈。我的/etc/php5/cli/php.ini文件的日期是2013年10月,这表明Ubuntu13.10设置了它;也许那个版本复制了错误的文件。Ubuntu升级会更新/usr/share/php5中的示例文件,但不会影响/etc/中的文件。

为了修复它,我使用了

代码语言:javascript
复制
$ sudo cp -pi /usr/share/php5/php.ini-production.cli /etc/php5/cli/php.ini

若要复制默认命令行设置文件,请执行以下操作。显然,如果您对命令行PHP5设置进行了更改,这将覆盖它们;使用您的UNIX技能来比较和合并它们。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16262854

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档