一、安装Redis

1.下载安装包

wget http://download.redis.io/releases/redis-2.8.6.tar.gz

2.解压包

tar xzf redis-2.8.6.tar.gz

3.编译

cd redis-2.8.6

make

出现 “-bash:make:command not find”错误

解决方法:

rpm -qa | grep make

提示只安装了automake包

yum install make

yum install imake

OK!

make   /*再次编译*/

4.编译测试

make test

提示“You need tcl 8.5 or newer in order to run the Redis test”错误

解决方法:

安装tcl

wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz

cd tcl8.6.1-src

cd unix

./configure --prefix=/usr           \

--without-tzdata        \

--mandir=/usr/share/man \

$([ $(uname -m) = x86_64 ] && echo --enable-64bit) &&

make &&sed -e "s@^\(TCL_SRC_DIR='\).*@\1/usr/include'@" \

-e "/TCL_B/s@='\(-L\)\?.*unix@='\1/usr/lib@" \

-i tclConfig.shmake install &&

make install-private-headers &&

ln -v -sf tclsh8.6 /usr/bin/tclsh &&

chmod -v 755 /usr/lib/libtcl8.6.so

再次测试编译

cd redis-2.8.6

make test

4.配置redis

vim redis.conf

daemonize yes #使得进程在后台运行

dir /usr/lcoal/redis/db  #磁盘存储redis数据库文件位置

5.启动redis

cd src

./redis-server

提示“Warning: no config file specified,using the default config.In order to specify a config file use ./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....“两个警告

安装提示操作:

①修改sysctl文件,/sbin/sysctl -p,使修改生效

②./redis-server /etc/redis.conf  以这种方式启动redis服务 (我将配置文件移到了/etc目录下)

6.体验redis

> cd src

> ./redis-cli   #启动redis客户端

> ping

PONG

> set foo bar

OK

> get foo

"bar"

> incr mycounter

(integer) 1

> incr mycounter

(integer) 2

7.安装redis

将redis二进制文件安装在/usr/local/bin目录

make install

8.redis安全

进入redis客户端默认无需密码,可通过配置文件修改密码

① vim /etc/redis.conf

加上:requirepass cJHzy2Z2T8csYspcwwsODHApNko9tg

② 重启redis

kill 26743(redis进程号)

/usr/local/bin/redis-server /etc/redis.conf

③ 使用redis

/usr/local/bin/redis-cli 也可/usr/local/bin/redis-cli -a 密码 进入客户端

> set h2 helloworld

(error) NOAUTH Authentication required.

> auth cJHzy2Z2T8csYspcwwsODHApNko9tg

OK

> get h2

(nil)

> set h3 abc

> get h3

"abc"

也可通过config set命令动态修改密码

> config get requirepass

1) "requirepass"

2) "cJHzy2Z2T8csYspcwwsODHApNko9tg"

> config set requirepass UHLc565HXduJ5730g8tAcsvNxRUQhY

OK

> auth UHLc565HXduJ5730g8tAcsvNxRUQhY

> set h6 kkkkk

OK

> get h6

"kkkkk"

> exit

查看配置文件,还是原密码,表示config未保存至配置文件

requirepass cJHzy2Z2T8csYspcwwsODHApNko9tg

二、安装redis的php客户端

1.安装git

yum install git

git clone https://github.com/nicolasff/phpredis.git

2.用phpize扩展php扩展模块

/usr/bin/phpize

出现”Cannot find config.m4.Make sure that you run '/usr/bin/phpize' in the top level source direcotory of the module“错误

解决方法:

wget http://ftp.gnu.org/gnu/m4/m4-1.4.9.tar.gz
tar -zvxf m4-1.4.9.tar.gz
cd m4-1.4.9/
./configure && make && make install

还是不行,接着

cd phpredis

/usr/bin/phpize   (里面有config.m4所以可以使用phpize)

ok!

3.配置

./configure --with-php-config=/usr/bin/php-config

4.编译和安装

make && make install

5.修改php的配置文件

cd/etc/php.d

vim redis.ini

加上extension=redis.so

6.重启apache

service httpd restart

7.测试

phpinfo();查看redis是否正确安装

三、参考资料

redis官网 http://redis.io/

redis命令 http://redis.io/commands

tcl安装 http://www.linuxfromscratch.org/blfs/view/cvs/general/tcl.html

通过epel 安装redis http://blog.sina.com.cn/s/blog_6364150101019701.html

http://www.codesky.net/article/201110/170019.html

EPEL(Extra Packages for Enterprise Linux) http://fedoraproject.org/wiki/EPEL

Redis — CentOS6.4安装Redis以及安装PHP客户端phpredis的更多相关文章

  1. centos6.7用yum安装redis解决办法及IP限制配置

    在centos6.7用yum安装redis解决办法 - bluesky1 - 博客园 http://www.cnblogs.com/lanblogs/p/6104834.html yum instal ...

  2. centos6.5环境Redis下载及编译安装

    centos6.5环境Redis下载及编译安装 1:官方站点: http://redis.io/download 下载最新版或者最新stable版 2:解压源码并进入目录 tar -zxvf redi ...

  3. centos6.8下redis的安装和配置

    centos6.8下redis的安装和配置 下载.安装 在redis官网可以获取到最新版本的redis 进入/usr/local/目录,执行如下命令 wget http://download.redi ...

  4. centos6.3下yum安装redis

    我得是centos 6.3,如果直接用yum安装redis,报错,如下: [root@CentOS6 etc]# yum install redis Loaded plugins: fastestmi ...

  5. Centos6.10编译安装php-7.1.12并安装redis模块

    1.服务器初始化 yum update -yyum install epel-release -yyum install gcc gcc-c++ wget lsof lrzsz telnet -y 2 ...

  6. CentOS6.9安装redis

    目录 Centos6.9下的Redis安装和配置(最简易方式) redis客户端登录方式 Centos6.9下的Redis安装和配置(最简易方式) 在服务器上创建一个目录/service,然后下载re ...

  7. centos6.7安装Redis

    1.创建安装目录 mkdir /usr/local/redis cd /usr/local/src 2.获取安装包:wget http://download.redis.io/releases/red ...

  8. 在centos6.7用yum安装redis解决办法

    1. centos默认的安装源在官方centos.org上,而Redis在第三方的yum源里,所以无法安装,非官方的yum推荐用fedora的epel仓库 [root@localhost instal ...

  9. Centos6 安装 Redis

    先确认gcc和tcl已经安装 sudo yum install gcc-c++ sudo yum install tcl 解压, 编译和安装 .tar.gz /usr/src/ cd /usr/src ...

  10. 在centos6.3用yum安装redis

    一.centos默认的安装源在官方centos.org上,而redis在第三方的yum源里,所以无法安装,非官方的yum推荐用fedora的epel仓库.当然也可通过配置 /etc/yum.repos ...

随机推荐

  1. HDU 2517 棋盘分割

    题意:n刀切割棋盘 下面是8*8的棋盘,每个数字代表棋盘对应点的权值,问切割n刀后,每一块的和  的均方差最小是多少 均方差的公式需要先化简: 由上式得,均方差最小 显然是要 Xi^2 最小 d[k] ...

  2. easyui valid

    /** * 包含easyui的扩展和常用的方法 * * @author * * @version 20120806 */ var wjc = $.extend({}, wjc);/* 定义全局对象,类 ...

  3. JavaScript常用正则表达式与应用(一)

    JavaScript的String类和RegExp对象类都定义了相关方法使用正则表达式进行模式匹配,本文将以连载方式介绍JavaScript常用正则表达式与相关应用,欢迎交流 本节是连载一,首先介绍J ...

  4. J2EE之ServletContext读取资源文件

    ServletContext读取资源文件内容的方式有两种: 方法1. public void doGet(HttpServletRequest request, HttpServletResponse ...

  5. [Webpack 2] Use Karma for Unit Testing with Webpack

    When writing tests run by Karma for an application that’s bundled with webpack, it’s easiest to inte ...

  6. Linux内核分析:页回收导致的cpu load瞬间飙高的问题分析与思考--------------蘑菇街技术博客

    http://mogu.io/156-156 摘要 本文一是为了讨论在Linux系统出现问题时我们能够借助哪些工具去协助分析,二是讨论出现问题时大致的可能点以及思路,三是希望能给应用层开发团队介绍一些 ...

  7. [转] React Native Navigator — Navigating Like A Pro in React Native

    There is a lot you can do with the React Native Navigator. Here, I will try to go over a few example ...

  8. 使用nexus创建maven私有仓库

    nexus安装 nexus下载 wget https://sonatype-download.global.ssl.fastly.net/nexus/oss/nexus-2.11.1-01-bundl ...

  9. Java并发——线程池Executor框架

    线程池 无限制的创建线程 若采用"为每个任务分配一个线程"的方式会存在一些缺陷,尤其是当需要创建大量线程时: 线程生命周期的开销非常高 资源消耗 稳定性 引入线程池 任务是一组逻辑 ...

  10. Java并发(6)带返回结果的任务执行

    携带结果的任务 JDK5提供了有可返回值的任务的执行.java.util.concurrent中Callable与Futrue用以实现带返回值的任务执行. 使用Callable与Futrue与使用Ru ...