Enable PCNTL in Ubuntu PHP - test fails

前端 未结 5 1655
隐瞒了意图╮
隐瞒了意图╮ 2021-02-08 05:05

I need help on How to: Enable PCNTL in Ubuntu PHP.

$ mkdir /tmp/phpsource
$ cd /tmp/phpsource


$ wget http://museum.php.net/php5/php-5.3.2.tar.gz
$ tar xvf php-         


        
相关标签:
5条回答
  • 2021-02-08 05:42

    There is some steps like this: (my OS is debian7.2 xfce x86).

    1: i install pcntl like this

    #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.

    "PHP Warning: Module ‘pcntl’ already loaded in Unknown on line 0"

    3: so i

    "rm -rf /etc/php5/mods-available/pcntl.ini and /etc/php5/conf.d/pcntl.ini"

    4: edit the "php.ini" file .

    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.

    0 讨论(0)
  • 2021-02-08 05:47

    I NEEDED to restart the server! And now it works! Doh.. Thanks for everybodys input.

    0 讨论(0)
  • 2021-02-08 05:51

    Here's what I've found in 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_setpriority
      
    • phpinfo reports the function is already loaded but it will not actually work without putting the pcntl.ini file into /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.

    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.

    Line 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)
    
    0 讨论(0)
  • 2021-02-08 05:51

    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:

    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.

    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.

    0 讨论(0)
  • 2021-02-08 06:01

    On my dev machine with ubuntu 12.10 (and earlier versions too) pcntl is/was already enabled.

    $ php -m | grep pcntl
    pcntl
    

    I guess thats the problem:

    PHP Warning: Module 'pcntl' already loaded in Unknown on line 0

    So just don't install it again.

    0 讨论(0)
提交回复
热议问题