zoukankan      html  css  js  c++  java
  • Redis — CentOS6.4安装Redis以及安装PHP客户端phpredis

    一、安装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 26743redis进程号)

    /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

    二、安装redisphp客户端

    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

     

     

     

     

     

     

     

     

     

  • 相关阅读:
    字符集WideCharToMultiByte
    [HDF]hdf-4.2.6类库的使用
    [GDAL]读取HDF格式的calipso数据
    C#读写BitMap及颜色相乘
    [Slimdx]顶点和索引缓冲,绘制了2个分离的三角形
    [GDAL]写入shp
    几个环境学概念
    MIConvexHull
    几个力学概念
    [转载]如何破解Excel VBA密码
  • 原文地址:https://www.cnblogs.com/luoyunshu/p/3635583.html
Copyright © 2011-2022 走看看