Problem Descriptio
n:
[Root@localhost www]#/usr/local/php/bin/php index.php
PHP Fatal error:call to undefined function pcntl_fork () in/home/www/theard/threadprocessmanager.php on line 69
Workaround:
1. New PHP Compilation
./configure--enable-pcntl "" "
2, do not reinstall can also, directly into your installation of PHP source directory ext/pcntl directory.
Run
Phpize
[Root@localhost pcntl]#./configure--with-php-config=/usr/local/php/bin/php-config && make && make Install
Put the generated files in the default directory:
[Root@localhost pcntl]# cp/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/pcntl.so/usr/lib/php/ modules/
and add this extension to the php.ini.
Extension=pcntl.so
If you do not add it directly in your program (with the DL () function, the function will be canceled) can also, especially for PHP in addition to CmdLine and Apache do web work, because the Web service load PNCTL module love problems.
Test method
test_fork.php:
echo "This was an echo before I called the fork command\n";
$pid = Pcntl_fork ();
if ($pid = =-1) {
Die ("Could not fork");
} else if ($pid) {
echo "I am the parent, PID =". $pid. " \ n ";
} else {
echo "I am the child, PID =". $pid. " \ n ";
}
echo "This is a echo after I called the fork command\n";
?>