zoukankan      html  css  js  c++  java
  • CentOS 6.5 下安装 Redis 2.8.7

    wget http://download.redis.io/redis-stable.tar.gz

    tar xvzf redis-stable.tar.gz

    cd redis-stable

    make

    前面3步应该没有问题,主要的问题是执行make的时候,出现了异常。

    异常一:

    make[2]: cc: Command not found

    异常原因:没有安装gcc

    解决方案:yum install gcc-c++

    异常二:

    zmalloc.h:51:31: error: jemalloc/jemalloc.h: No such file or directory

    异常原因:一些编译依赖或原来编译遗留出现的问题

    解决方案:make distclean。清理一下,然后再make。

    在make成功以后,需要make test。在make test出现异常。

    异常一:

    couldn't execute "tclsh8.5": no such file or directory

    异常原因:没有安装tcl

    解决方案:yum install -y tcl。或者:

    1. wget http://downloads.sourceforge.net/tcl/tcl8.5.10-src.tar.gz 
    2. tar xzvf tcl8.5.10-src.tar.gz 
    3. cd tcl8.5.10/unix/
    4. ./configure 
    5. make&&make install

    运行make test

    #cd /home/sandea/redis-stable

    #make test

    在make test成功以后,make install

    #make install

    测试通过后安装,安装后会自动把redis-server,redis-cli,redis-benchmark,redis-check-aof,redis-check-dump复制到/usr/local/bin目录下

    编辑redis.conf文件

    #mkdir /etc/redis
    #cp redis.conf /etc/redis/redis.conf
    #vi /etc/redis/redis.conf

    daemonize yes

    pidfile /var/run/redis.pid

    logfile /etc/redis/redis.log

    编写自init.d脚本

    #vi /etc/init.d/redis

    内容如下:

    ###########################
    #chkconfig: 2345 10 90
    #description: Start and Stop redis
    PATH=/usr/local/bin:/sbin:/usr/bin:/bin

    REDISPORT=6379
    EXEC=/usr/local/bin/redis-server
    REDIS_CLI=/usr/local/bin/redis-cli

    PIDFILE=/var/run/redis.pid
    CONF="/etc/redis/redis.conf"

    case "$1" in
    start)
    if [ -f $PIDFILE ]
    then
    echo "$PIDFILE exists, process is already running or crashed"
    else
    echo "Starting Redis server..."
    $EXEC $CONF
    fi
    if [ "$?"="0" ]
    then
    echo "Redis is running..."
    fi
    ;;
    stop)
    if [ ! -f $PIDFILE ]
    then
    echo "$PIDFILE does not exist, process is not running"
    else
    PID=$(cat $PIDFILE)
    echo "Stopping ..."
    $REDIS_CLI -p $REDISPORT SHUTDOWN
    while [ -x ${PIDFILE} ]
    do
    echo "Waiting for Redis to shutdown ..."
    sleep 1
    done
    echo "Redis stopped"
    fi
    ;;
    restart|force-reload)
    ${0} stop
    ${0} start
    ;;
    *)
    echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&2
    exit 1
    esac
    ##############################

    保存,给redis授权:

    #chmod +x /etc/init.d/redis

    设置开机自动启动服务:

    #chkconfig redis on

    启动服务:

    #service redis start

    停止服务:

    #service redis stop

     调试:

    #redis-cli -h 127.0.0.1 -p 6379

    #set hello "word"

    #get hello

    "word"

    2.安装PhpRedis

    phpize

    phpredis属于php扩展,所以需要phpize,如果你的服务器没有安装phpize,要先安装

     #安装phpize  
    1. yum install php-devel  

    下载源码包

    直接用wget好了

     #wget下载github上的文件  
    1. wget https://github.com/nicolasff/phpredis/archive/master.zip  

    unzip

    下面要解压zip文件,首先,你,要,有个,unzip....

     #安装了这么多的软件,想想也该知道怎么装这个东西了吧  

    1. yum install unzip  

     #解压  
    1. unzip master.zip  

    编译

    下面正式开始编译php扩展

     #1.准备phpize编译环境  
    1. [root@localhost phpredis-master]# phpize  

    2. Configuring for:  

    3. PHP Api Version:         20090626  

    4. Zend Module Api No:      20090626  

    5. Zend Extension Api No:   220090626  


    再次ls就会发现文件夹中多了几个配置文件

     #2.配置环境  

    1. ./configure --with-php-config=/usr/local/php/bin/php-config --enable-vld  


    这个步骤会将上一步准备好的配置文件进行执行

     #3.编译  

    1. make && make install  


    balabala...........

     
    1. #编译完成  

    2. Build complete.  

    3. Don't forget to run 'make test'.  

    4. Installing shared extensions:     /usr/lib/php/modules/  

      6.cp /home/tools/phpredis-master/modules/redis.so   /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/redis.so

    修改php.ini

     
    1. [root@localhost phpredis-master]# vi /etc/php.ini  

    添加下面的扩展

    1. extension=redis.so  

    重启服务器

     
      1. [root@localhost modules]# service php-fpm restart  

      2. 停止 httpd:                                               [确定]  

      3. 正在启动 httpd:                                           [确定]  

  • 相关阅读:
    vsftpd 启动 vsftpd:500 OOPS: bad bool value in config file for: guest_enable
    Vsftpd服务传输文件(转)
    搭建FTP服务
    sed命令
    创建服务类脚本
    jvm 方法区
    B+与B-树
    适配器模式
    java 垃圾回收总结(可达性分析 引用分类
    HBase常见问题答疑解惑【持续更新中】
  • 原文地址:https://www.cnblogs.com/sandea/p/4575145.html
Copyright © 2011-2022 走看看