先下源碼編譯:php
git clone git://github.com/nicolasff/phpredis.git
cd ./phpredis
phpize #(可能會出錯,看最後面)git
./configure
make
make installgithub
而後編寫ini文件:redis
vim /etc/php.inishell
內容:apache
extension=redis.sovim
重啓apache(sudo /usr/sbin/apachectl restart),而後看看phpinfo()吧,應該有redis了。app
(phpize可能會出錯)測試
問題一:spa
執行執行 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