一、安装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. iOS Xcode的快捷键

    将一些搜集和经常使用的快捷键记录下来,方便你我. Command +1~ 8: 跳转到导航区的不同位置 Command +0 :显示/隐藏导航区 Command Alt 1~ 6:在不同检测器之间跳转 ...

  2. 织梦/dedecms 当文章转载时不需要设置图片水印的设置,取消’图片是否加水印‘的复选框,并且修改如下文件即可生效

    当想添加水印是选中“图片是否加水印”复选框即可. 找到include/helpers/image.helper.php这个文件,在里面找到中的if( isset($GLOBALS['needwater ...

  3. ubuntu14.04启动提示set_sw_state failed

    安装上ubuntu14.04时,系统启动时一直出现一个问题 kernel: [ 16.465893] [drm:rv770_dpm_set_power_state] *ERROR* rv770_set ...

  4. Android ListFragment实例Demo(自己定义适配器)

    上一篇文章介绍了ListFragment,当中的ListView并没有自己定义适配器,实际上在实际开发中常会用到自己定义适配器,是实现更复杂的列表数据展示. 所以这篇文章添加了自己定义适配器.来进行L ...

  5. MySQL参数优化

    目前针对MySQL数据库进行了一些参数优化,具体如下: my.ini / my.cnf 参数说明 #使用查询缓存 query_cache_size=100M                     # ...

  6. Mysql性能优化之缓存参数优化

    数据库属于 IO 密集型的应用程序,其主要职责就是数据的管理及存储工作.而我们知道,从内存中读取一个数据库的时间是微秒级别,而从一块普通硬盘上读取一个IO是在毫秒级别,二者相差3个数量级.所以,要优化 ...

  7. java14 处理流

    二.处理流 .引用类型,保留数据+类型 序列化:将对象保存到文件或者字节数组中保存起来,叫序列化.输出流:ObjectOutputStream.writeObject(). 反序列化:从文件或者字节数 ...

  8. careercup-排序和查找 11.5

    11.5 有个排序后的字符串数组,其中散布着一些空字符串,编写一个方法,找出给定字符串的位置. 解法: 如果没有那些空字符串,就可以直接使用二分查找法.比较待查找字符串str和数组的中间元素,然后继续 ...

  9. last_9t's_ramsey

    cannot finish his face

  10. Java代码安全测试解决方案

    Java代码安全测试解决方案: http://gdtesting.com/product.php?id=106