centos安装redis

原稿采自:http://blog.csdn.net/21aspnet/article/details/6960757

第一步:下载安装编译

#wget http://redis.googlecode.com/files/redis-2.4.4.tar.gz
#tar zxvf redis-2.4.4.tar.gz
#cd redis-2.4.4
#make
#make install
#cp redis.conf  /etc/

第二步:修改配置

#vi /etc/redis.conf
 
配置见附录
 

第三步:启动进程

#redis-server /etc/redis.conf

查看进程有没有成功启动

#ps -ef | grep redis
测试输入一个键值
#redis-cli set test “123456″
获取键值
#redis-cli get test
 
 

关闭redis
# redis-cli shutdown      //关闭所有
关闭某个端口上的redis
# redis-cli -p 6397 shutdown  //关闭6397端口的redis

说明:关闭以后缓存数据会自动dump到硬盘上,硬盘地址见redis.conf中的dbfilename  dump.rdb

PHP扩展

http://code.google.com/p/php-redis/

可以参考:

Redis的部署使用文档  http://www.elain.org/?p=505

========================================================

安装PHP的Redis扩展

先去下载https://github.com/nicolasff/phpredis/downloads

#wget https://github.com/nicolasff/phpredis/downloads

# tar -zxvf nicolasff-phpredis-2.1.3-124-gd4ad907.tar.gz
# mv nicolasff-phpredis-d4ad907 php-5.3.8/ext/phpredis/
# cd php-5.3.8/ext/phpredis/
# /usr/local/php/bin/phpize
# ./configure –with-php-config=/usr/local/php/bin/php-config
# make && make install

配置php.ini

vi /usr/local/php/lib/php.ini
(加入:
extension=redis.so
)
先要看看有没有extension_dir=/…….
重启apache或者nginx

# /usr/local/apache2/bin/apachectl restart

测试代码:

[php] view plaincopy
 
  1. <?php
  2. $redis = new Redis();
  3. $redis->connect(’127.0.0.1′,6379);
  4. $redis->set(‘test’,'hello world!’);
  5. echo $redis->get(‘test’);
  6. ?>

参考:

Linux(CentOS 5.5) Redis 安装及RedisPHP拓展安装应用

http://www.linuxidc.com/Linux/2011-08/41404.htm
安装redis和phpredis模块

http://skandgjxa.blog.163.com/blog/static/14152982011712112933816/

RHEL5下编译安装Redis及其PHP扩展库

http://hi.baidu.com/zjstandup/blog/item/9f38b825d379c96c35a80f7f.html

原文地址:https://www.cnblogs.com/findgor/p/4086493.html