Redis以及Redis的php扩展安装

redis下载:
  http://redis.io/download
php-redis下载:
  https://github.com/nicolasff/phpredis
参考书籍:
  https://github.com/JasonLai256/the-little-redis-book/blob/master/cn/redis.md

安装redis:
  wget http://redis.googlecode.com/files/redis-2.4.6.tar.gz
  tar -zxvf redis-2.4.6.tar.gz
  cd redis-2.4.6
  make
  make install
  cp redis.conf  /etc/

启动redis:
  src/redis-server /etc/redis.conf

开始客户端:
  src/redis-cli

关闭redis:
  redis-cli shutdown      //关闭所有
  redis-cli -p 6397 shutdown  //关闭6397端口的redis  

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

可能得报错信息:
  Warning: no config file specified, using the default config. In order to specify a config file use 'redis-server /path/to/redis.conf'
  警告:没有明确的config文件,使用默认配置。为了明确配置文件请使用'redis-server /path/to/redis.conf'
  WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
  警告:过量使用内存设置为0!在低内存环境下,后台保存可能失败。为了修正这个问题,请在/etc/sysctl.conf 添加一项 'vm.overcommit_memory = 1' ,然后重启(或者运行命令'sysctl vm.overcommit_memory=1' )使其生效。


安装php-redis
  cd phpredis
  /usr/local/php/bin/phpize #这个phpize是安装php模块的
  ./configure –with-php-config=/usr/local/php/bin/php-config
  make
  make install

  配置php.ini:
    加入extension=redis.so
    先要看看有没有extension_dir=/....
    重启apache或者nginx
    测试代码:
    <?php
      $redis = new Redis();
      $redis->connect('127.0.0.1',6379);
      $redis->set('test','hello world!');
      echo $redis->get('test');

    ?>

转自:http://blog.csdn.net/21aspnet/article/details/6960757




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值