PHP Fatal error:call to undefined function pcntl_fork () in/home/www/theard/threadprocessmanager.p____php

Source: Internet
Author: User

Http://www.cnblogs.com/nwf5d/archive/2011/03/29/1999115.html

Problem Description:

[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 in line 69 Solution:


1, the new compiler PHP

./configure--enable-pcntl "" "

2, do not reinstall also can, 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 then add this extension to the php.ini.
Extension=pcntl.so
If you do not add it directly to 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 when loading Pnctl module love problems.

Test methods


test_fork.php:

?
echo "This is 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";
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.