redis的下载及安装:
@ubuntu:/$ mkdir /usr/local/redis
@ubuntu:/$ cd /usr/local/redis
@ubuntu:/$ wget http://imgs.blucds.com/soft/linux/redis/redis-2.6.14.tar.gz
@ubuntu:/$ tar xzf redis-2.4.2.tar.gz
@ubuntu:/$ cd redis-2.4.2
@ubuntu:/$ make
@ubuntu:/$ src/redis-server
redis测试命令:
@ubuntu:/$ src/redis-cli
@ubuntu:/$ redis> set foo bar
@ubuntu:/$ OK
@ubuntu:/$ redis> get foo
@ubuntu:/$ "bar";
详细配置请参阅:
CentOS系统下 Redis 2.6.14版安装配置详解装了redis的服务器端程序,现在要在项目中使用REDIS了,由于我们的后台是用PHP来写的,所以要用redis的PHP客户端来使用它。PHP的客户端有几种:
Predis ★ Repository JoL1hAHN Mature and supported
phpredis ★ Repository yowgi This is a client written in C as a PHP module.
Rediska Repository Homepage shumkov
Redisent Repository justinpoliey
iRedis Repository dhorrigan
在这里我选择phpredis( C开发的扩展包 )这个PHP扩展。
@ubuntu:/$ wget http://imgs.blucds.com/soft/linux/redis/owlient-phpredis-2.1.1-1-g90ecd17.tar.gz
@ubuntu:/$ tar zxvf owlient-phpredis-2.1.1-1-g90ecd17.tar.gz
@ubuntu:/$ cd owlient-phpredis-90ecd17/
@ubuntu:/$ /usr/local/php/bin/phpize
@ubuntu:/$ ./configure --with-php-config=/usr/local/php/bin/php-config
@ubuntu:/$ make
@ubuntu:/$ make install
注:用C开发PHP扩展的时候如果用动态链接库的方式编译扩展模块,需要用到phpize,这个工具在使用apt-get install php5默认情况也是没安装的,安装phpize:apt-get install php5-dev。
修改配置文件:
修改php.ini文件
在php.ini中添加如下一行:
extension=redis.so
重启nginx后生效。
最后开启redis服务:redis-server 或者 redis-server /etc/redis.conf(后台运行), 如果不开服务可能会出现 ”Uncaught exception 'RedisException' with message 'Redis server went away'?“错误