docker php容器中 Call to undefined function pcntl_fork() 解决方法

问题:docker容器中使用pcntl_fork函数,提示报错:
root@b7204f45ed02:/var/www/: php -r "echo pcntl_fork();";
PHP Fatal error:  Uncaught Error: Call to undefined function pcntl_fork() in Command line code:1
Stack trace:
#0 {main}
  thrown in Command line code on line 1
解决步骤
1. 下载php源码文件 
wget https://www.php.net/distributions/php-7.2.18.tar.gz -P /home/
2. 解压 tar -xvf /home/php-7.2.18.tar.gz
3. cd /home/php-7.2.18/ext/pcntl/
4. phpize
5. 
   ./configure && make
6. 查看扩展目录 
php -i | grep "extension_dir"
7. 拷贝so到扩展目录 
cp /home/php-7.2.18/ext/pcntl/modules/pcntl.so /usr/local/lib/php/extensions/no-debug-non-zts-20170718
8. 修改ini配置 
echo "extension=pcntl.so" >> php.ini

你可能感兴趣的:(docker php容器中 Call to undefined function pcntl_fork() 解决方法)