PHP安装多进程pcntl扩展



# mkdir php
# cd php
# apt-get source php5
# cd php5-(WHATEVER_RELEASE)/ext/pcntl
# phpize
# ./configure (注一)
# make
# make install


7.复制pcntl/module文件夹下的pcntl.so文件到自定义位置

8.在php.ini文件中添加extension=上一步自定义位置/pcntl.so

9.重启apache



如报错误:

sed -i 's|PHP_FE_END|{NULL,NULL,NULL}|' ./ext/pcntl/*.c

sed -i 's|ZEND_MOD_END|{NULL,NULL,NULL}|' ./ext/pcntl/*.c


注一:./configure --with-php-config=/opt/app/php5/bin/php-config

phpize:yum install php-devel  或者 apt-get install php5-dev #提供phpize命令支持

注意版本,必须用当前PHP版本的phpize  /opt/app/php5/bin/phpize


$cmds=array(        array('/apps/bin/launcher.php','charge/promotion_props_stat.php','mobile',1),        array('/apps/bin/launcher.php','charge/promotion_props_stat.php','mobile',2),        array('/apps/bin/launcher.php','charge/promotion_props_stat.php','click',1),        array('/apps/bin/launcher.php','charge/promotion_props_stat.php','click',2),        array('/apps/bin/launcher.php','charge/promotion_props_stat.php',1),        array('/apps/bin/launcher.php','charge/promotion_props_stat.php',2)
);foreach($cmds as $cmd){        $pid=pcntl_fork();        if($pid==-1){ //进程创建失败
                die('fork child process failure!');
        }        else if($pid){ //父进程处理逻辑
                pcntl_wait($status,WNOHANG);
        }        else{ //子进程处理逻辑
                pcntl_exec('/usr/local/bin/php',$cmd);
        }
}


你可能感兴趣的:(PHP,多进程)