为Mac OS X 中的MAMP安装 libmosquitto PHP扩展
2019独角兽企业重金招聘Python工程师标准>>>
进入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就安装成功了。
转载于//my.oschina.net/fangyisheng/blog/717336
还没有评论,来说两句吧...