Mac OS X内置PHP如何扩展'pcntl'

发布于 2022-09-01 22:25:35 字数 1624 浏览 28 评论 0

最近公司需要搭建Phabricator服务,用到了LAMP套件,其中在配置PHP时,需要扩展'pcntl'使用多进程,但在扩展时遇到了麻烦:

系统:
Mac OSX EI Capitan

PHP版本信息:(Mac OSX自带)
PHP 5.5.27 (cli) (built: Aug 22 2015 18:20:44)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies

具体情况如下:
使用 cpoptdeiMac:phabricator cpopt$ ./bin/phd start命令,终端提示

ERROR: The PHP extension 'pcntl' is not installed. You must install it to run daemons on this machine.

网上的安装'pcntl'基本上都是下面的方法:

首先下载一个php-5.4.24源代码包
进入源代码目录的 ext/pcntl/
cd /path/to/phpsrc/ext/pcnt/
phpize
make
sudo
make install
最后记得要修改系统php的php.ini,加载pcntl.so模块

我尝试了上面的方法,重新下载了一个对应版本的PHP安装包,执行上面的命令,但一直报下面的错误:

cpoptdeiMac:pcntl cpopt$ pwd
/Users/cpopt/Downloads/php-5.5.27/ext/pcntl
cpoptdeiMac:pcntl cpopt$ phpize
grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:        
Zend Module Api No:     
Zend Extension Api No:  
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

cpoptdeiMac:pcntl cpopt$ 

于是我又Google了半天,找到这个问题的解决方案如下,但是也是出错,提示非法操作

cpopt$ sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include

目前为止,已经耗了一天时间了还没有解决,希望大家能够帮助我渡过难关!谢谢!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

谁与争疯 2022-09-08 22:25:35

我也有类似的报错:

    grep: /usr/include/php/main/php.h: No such file or directory
    grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
    grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
    Configuring for:
    PHP Api Version:
    Zend Module Api No:
    Zend Extension Api No:

最后在stackoverflow 上找到一个类似的问题

  • xcode-select —install 先安装 xcode命令行工具就可以了,原因暂时不知

  • ./configure

  • sudo make

  • sudo make install
    最后出现错误(移动so文件出问题)

           Installing shared extensions:     /usr/lib/php/extensions/no-debug-non-zts-20121212/
           cp: /usr/lib/php/extensions/no-debug-non-zts-20121212/#INST@5555#: Operation not permitted
           make: *** [install-modules] Error 1
    
    就是sudo自己移动也出问题  
    
           cp: /usr/lib/php/extensions/no-debug-non-zts-20121212/pcntl.so: Operation not permitted
    
  • 默认的php扩展库的位置不能移动进去,就移动自己建的目录中,之后再配置设置自己的文件目录就行了

    `sudo mkdir /usr/local/my-php-ext`  
    `sudo cp ./modules/pcntl.so /usr/local/my-php-ext/pcntl.so`   (编译好的pcntl文件在./modules 中)
    
  • sudo echo 'extension=/usr/local/my-php-ext/pcntl.so' >> /etc/php.ini

  • sudo apachectl restart 重启apache

  • 查看是否安装成功

       $ php -ini | grep pcntl
       pcntl
       pcntl support => enabled
       PWD => /Users/andyron/myfield/www/test/php-src-php-5.5.34/ext/pcntl
       _SERVER["PWD"] => /Users/andyron/myfield/www/test/php-src-php-5.5.34/ext/pcntl
死开点丶别碍眼 2022-09-08 22:25:35

哥们解决了吗?? 我在MAC下也遇到了同样的问题

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文