2013-04-28 11 views
18

thisの記事を使用して、私のPHP 5.4.6をUbuntuの32ビット版12.10で動作させるためにpcntlをインストールしました。pcntlがセキュリティ上の理由でUbuntuで動作していない

コンパイル後、実行時にmake testに次のエラーが発生したため、スムーズに進まなかった。

警告::pcntl_forkは()/var/www/mydev/dev/mailServiceTest.phpにおけるセキュリティ上の理由で無効にされた私は、私が言う子プロセスをforkしようとしているたびに警告を取得していますon line 8

私はWeb上ですべてのソリューションを検索しましたが、残念ながら私は他の場所ではこの問題について言及していませんでした。次のコマンドを入力するとき、私はすべてでは、この拡張機能をインストールする前に、PHPインタプリタが関数を認識しませんでしたが、PHPが実際に既にインストールされているようです

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 [email protected] 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): [email protected] 

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

Thank you for helping to make PHP better. 
[email protected]:/php/php-5.4.6/ext/pcntl$ version 

[email protected]:/php/php-5.4.6/ext/pcntl$ php -m | grep pcntl 
PHP Warning: Module 'pcntl' already loaded in Unknown on line 0 
pcntl 

どのようにすることができますこの機能を正しく設定するにはどうすればよいですか?

+1

これは、 'disable_functions'の設定から削除してください(' php -d disable_functions = pcntl_fork -r 'pcntl_fork(); 'または' php -d disable_functions = substr -r' substr( 1); ''その問題について)。 Webサーバーをフォークするのは悪い考えです。 – Wrikken

+0

ありがとうございますが、私はCLI sapiでこのスクリプトを使用していますので、うまくいくはずです –

答えて

37

はsudo geditの

sudo gedit /etc/php5/cli/php.ini 

または\と

sudo gedit /etc/php5/apache2/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 

コメントこのうち:

;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 
+7

あなたの_cli_スクリプトが/ etc/php5/_apache2_ /php.iniをロードする理由は何ですか? – Wrikken

+1

GUIを使用してrootアクセスが必要な場合は、代わりに 'gksudo'を使用してください:http://askubuntu.com/a/11766/63492 –

+0

こんにちはAditya、指定された答えは、ここではそうではありませんが、php.iniファイルはWebサーバーユーザー(Apacheの場合はwww-data)によって所有されていますが、悪い場合はroot自身によって所有されています。 –

0

私もこのPROBを持っていましたレム。 UbuntuにはいくつかのサンプルPHP設定ファイルが付属しています。/usr/share/php5php.ini-productionはApache WebサーバーのPHP設定(/etc/php5/apache2/php.ini)のテンプレートで、pcntl_forkと他の機能を無効にします。 php.ini-production.cliは、テストを実行しているときを含め、コマンドライン(/etc/php5/cli/php.ini)から実行されるPHPのテンプレートであり、機能を無効にしません。しかし、どういうわけか私の/etc/php5/cli/php.iniは、これらの機能を無効にするApache設定のコピーでした。

どうしたのか分かりません。 Ubuntu 12.04でLAMPスタックをインストールしました。私の/etc/php5/cli/php.iniファイルは2013年10月からのもので、Ubuntu 13.10のセットアップを示唆しています。おそらく、そのリリースが間違ったファイルをコピーしたのかもUbuntuのアップグレードでは/usr/share/php5のサンプルファイルが更新されますが、ファイルは/etc/のままです。それを修正する

私は、デフォルトのコマンドライン設定ファイルをコピーする

$ sudo cp -pi /usr/share/php5/php.ini-production.cli /etc/php5/cli/php.ini 

を使用。明らかに、コマンドラインのPHP5設定を変更した場合は、これが上書きされます。 UNIXスキルを使用してそれらを比較し、マージします。

関連する問題