PHP Fatal error: Uncaught Error: Call to undefined function pcntl_fork().. 开启php pcntl扩展实现多进程
在使用函数pcntl_fork()时报错 Fatal error: Uncaught Error: Call to undefined function pcntl_fork()....,原因是没有安装pcntl扩展包,有两种解决方式,一种是在编译php的时候加上./configure --enable-pcntl,另一种是进入php源码的安装目录,运行phpize。
这里我选择第二种方式,进入压缩包目录
# pwd
/usr/local/src/php-7.1.10/ext/pcntl
# phpize
Configuring for:
PHP Api Version: 20160303
Zend Module Api No: 20160303
Zend Extension Api No: 320160303
# ./configure --with-php-config=/usr/local/php/bin/php-config
# make && make install
----------------------------------------------------------------------
Build complete.
Don't forget to run 'make test'.
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/ //复制路径
# vim /usr/local/php/etc/php.ini
extension= /usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/pcntl.so //加入此行代码
修改保存后重启php,查看phpinfo
OK~