Call to undefined function pcntl_fork() ubuntu server apache
Asked Answered
R

1

0

I have a problem with pcnt_fork

I followed this tutorial for installation

instalation of 
pcntl
$ mkdir /tmp/phpsource
$ cd /tmp/phpsource
$ apt-get source php5
$ cd /tmp/phpsource/php5-*/ext/pcntl
$ phpize
$ ./configure
$ make
# then copy your module to php5 module-lib path (in my case:)
# and create an .ini-file to enable the module for sapi after graceful restart.

$ cp /tmp/phpsource/php5-*/modules/pcntl.so /usr/lib/php5/20090626/
$ echo "extension=pcntl.so" > /etc/php5/conf.d/pcntl.ini

on php.ini you need to 
; This directive allows you to disable certain functions for security reasons.
; It receives a comma-delimited list of function names. This directive is
; *NOT* affected by whether Safe Mode is turned On or Off.
; http://php.net/disable-functions
;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, 

but if I look into apache error log I have PHP Fatal error: Call to undefined function pcntl_fork() yet.!!

Ribbonwood answered 17/9, 2014 at 13:36 Comment(3)
did you get a chance to restart your webserver after editing php.iniAristaeus
See also if module appears into phpinfo()Lixiviate
Check https://mcmap.net/q/75245/-does-php-have-threading I got it following Francois Bourgeois answer (popen).Cyclograph
H
1

It is not possible to use the function 'pcntl_fork' when PHP is used as Apache module. You can only use pcntl_fork in CGI mode or from command-line.

Using this function will result in: 'Fatal error: Call to undefined function: pcntl_fork()'

http://php.net/manual/en/function.pcntl-fork.php

Hardware answered 17/9, 2014 at 13:41 Comment(2)
so how can I parallelized when PHP is used as Apache module?Ribbonwood
I found it works with exec('php scriptWithPcntl_fork.php',$output);Rioux

© 2022 - 2024 — McMap. All rights reserved.