環(huán)境
操作系統(tǒng): OS X EI Capitan 10.11.2
PHP版本:5.6.9
安裝步驟
安裝 redis
brew install redis
brew install autoconf
wget https://github.com/ijonas/dotfiles/raw/master/etc/redis.conf
sudo mv redis.conf /etc/redis.conf
redis-server /etc/redis.conf ##注意redis.conf 中指定 log 文件權(quán)限問(wèn)題
redis-cli #啟動(dòng) redis
安裝 phpredis
https://github.com/nicolasff/phpredis
cd phpredis
sudo phpize
./configure
make
sudo make install
** 使 php 支持 redis**
修改 php.ini 配置文件
php --ini | grep 'loaded'
查看是否安裝成功
php -m | grep redis
php -i | grep 'Redis Support'
運(yùn)行 demo 程序
<?php
//Connecting to Redis server on localhost
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$redis->set("tutorial-name", "Redis tutorial");
echo $redis->get("tutorial-name").chr(10);
參考
1、http://raphaelstolt.blogspot.jp/2010/05/installing-php-redis-extension-on-mac.html
2采记、http://www.tutorialspoint.com/redis/redis_php.htm
3谷羞、http://levi.yii.so/archives/2887