先下源码编译:

git clone git://github.com/nicolasff/phpredis.git
cd ./phpredis
phpize  #(可能会出错,看最后面)

./configure
make
make install

然后编写ini文件:

vim /etc/php.ini

内容:

extension=redis.so

重启apache(sudo /usr/sbin/apachectl restart),然后看看phpinfo()吧,应该有redis了。

 

 

(phpize可能会出错)

问题一:

执行执行 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:

解决办法:

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

PS:经测试,适用于 Yosemite (10.10) Xcode 6.0.1 (6A317)

 

 

 

问题二:

如果执行 phpize 提示如下错误:

Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable.

先安装Homebrew,然后安装 autoconf :

brew install autoconf