为Mac OS X 中的MAMP安装 libmosquitto PHP扩展

进入MAMP的目录,选择要安装libmosquitto扩展的PHP版本,比如:

cd /Applications/MAMP/bin/php/php5.3.29/bin

然后使用 ./pecl install mosquitto-beta 

*注:默认使用./pecl install mosquitto,即可查看当前mosquitto的哪个版本是最新的stable版本。例如:

./pecl install mosquitto
Failed to download pecl/mosquitto within preferred state "stable", latest release is version 0.3.0, stability "beta", use "channel://pecl.php.net/mosquitto-0.3.0" to install

安装顺利的话,会生成mosquitto.so在 /Applications/MAMP/bin/php/php5.3.29/lib/php/extensions/no-debug-non-zts-20090626 中。然后在php.ini中加入

extension=mosquitto.so

重启httpd即可。

但我在安装的时候出现了一些状况,特列出如下,以便大家借鉴:

1. autoconf 不存在

./pecl install mosquitto-beta
downloading Mosquitto-0.3.0.tgz ...
Starting to download Mosquitto-0.3.0.tgz (25,395 bytes)
.........done: 25,395 bytes
5 source files, building
running: phpize
grep: /Applications/MAMP/bin/php/php5.3.29/include/php/main/php.h: No such file or directory
grep: /Applications/MAMP/bin/php/php5.3.29/include/php/Zend/zend_modules.h: No such file or directory
grep: /Applications/MAMP/bin/php/php5.3.29/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.

ERROR: `phpize' failed

由于我安装了home brew , 所以直接 brew install autoconf 就成功的解决了这个问题。

2. 找不到 php.h 等头文件

上面日志也包含了phpize运行的错误:

running: phpize
grep: /Applications/MAMP/bin/php/php5.3.29/include/php/main/php.h: No such file or directory
grep: /Applications/MAMP/bin/php/php5.3.29/include/php/Zend/zend_modules.h: No such file or directory
grep: /Applications/MAMP/bin/php/php5.3.29/include/php/Zend/zend_extensions.h: No such file or directory

这个问题是由于 PECL 没有在当前MAMP的php版本目录中的include目前下找到对应的php头文件。解决这个问题的前提是安装了XCode,Xcode的SDK里面包含了PHP的相关头文件,所以可以进入到php5.3.29目录下,创建一个软链接,指向Xcode的PHP SDK。

cd /Applications/MAMP/bin/php/php5.3.29
ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/ include

然后重新执行pecl install mosquitto-beta就安装成功了。

转载于:https://my.oschina.net/fangyisheng/blog/717336

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值