• centos 6.8 配置 Redis3.2.5


    配置Redis3.2.5 与 php-redis

    一、配置Redis

    1、下载Redis3.2.5安装包

    [root@zhangsan /] wget http://download.redis.io/releases/redis-3.2.5.tar.gz
    2、解压、编译、安装redis-3.2.5:
    [root@zhangsan /]tar -zxvf redis-3.2.5.tar.gz -C /usr/src/
    [root@zhangsan /]cd /usr/src/redis-3.2.5/
    [root@zhangsan /]make && make install
    3、创建redis相关目录:
    [root@iZ2z /]mkdir -p /home/redis/bin
    [root@iZ2z /]mkdir -p /home/redis/log
    [root@iZ2z /]mkdir -p /home/redis/pid
    [root@iZ2z /]mkdir -p /home/redis/db
    4、将可执行文件复制到自己的安装目录:/home/redis/
     
    [root@iZ2z /]ln -s /usr/local/bin/redis-*   /home/redis/bin/
     
    5、复制配置文件到自己的安装目录:/home/redis/
     
    [root@iZ2z /]cp redis.conf /home/redis/
     
    6、进入自己的安装目录,编辑redis.conf配置文件:
     
    [root@iZ2ze /]cd /home/redis/
    [root@iZ2ze /]vim /home/redis/redis.conf
    #根据实际需要修改配置文件,以下仅供参考
      daemonize yes
      pidfile /home/redis/pid/redis.pid
      logfile /home/redis/log/redis.log
      dir /home/redis/db
      port 6379
    7、创建redis服务脚本,并赋予权限:vim /etc/init.d/redis 
    #!/bin/sh
    #
    # Simple Redis init.d script conceived to work on Linux systems
    # as it does use of the /proc filesystem.
    PATH=/home/redis/bin:/sbin:/usr/bin:/bin
    REDISPORT=6379
    EXEC=/home/redis/bin/redis-server
    CLIEXEC=/home/redis/bin/redis-cli
    PIDFILE=/home/redis/pid/redis.pid
    CONF="/home/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
            ;;
        stop)
            if [ ! -f $PIDFILE ]
            then
                    echo "$PIDFILE does not exist, process is not running"
            else
                    PID=$(cat $PIDFILE)
                    echo "Stopping ..."
                    $CLIEXEC -p $REDISPORT shutdown
                    while [ -x /proc/${PID} ]
                    do
                        echo "Waiting for Redis to shutdown ..."
                        sleep 1
                    done
                    echo "Redis stopped"
            fi
            ;;
        *)
            echo "Please use start or stop as first argument"
            ;;
    esac
    8、添加redis服务开机启动:
     
    [root@iZ2ze /] chmod a+x /etc/init.d/redis
     
    9、启动redis服务:
     
    [root@iZ2ze /] service redis start
    [root@iZ2ze /] ps -ef | grep redis
    [root@iZ2ze /] netstat -anptu | grep 6379
    10、测试OK
       
    [root@iZ2ze /]redis-cli set key1 hello 

    get key1
    quit 

    二、配置php-redis

    1.下载phpredis

    [root@iZ2ze /]git clone https://github.com/phpredis/phpredis.git 
    [root@iZ2ze /]cd phpredis

    2.开始编译phpredis扩展

    [root@iZ2ze /] make
    [root@iZ2ze /] make install

    3.安装配置phpredis扩展

    检查redis.so 库文件是否存在

    [root@iZ2z /]# cd /usr/lib64/php/modules
    [root@iZ2z modules]# ls
    redis.so  

    #修改php.ini配置文件

    [root@iZ2z modules] vim /etc/php.ini        //第881行

    extention=redis.so //添加这一行扩展配置

    [root@iZ2z modules] service php-fpm restart //重启php服务

    //如果未能安装成功 请检查php配置文件是否成功添加配置并重启服务

     

    参考文章:http://www.cnblogs.com/jeffen/p/6066325.html?utm_source=itdadao&utm_medium=referral

                      http://www.cnblogs.com/jimmy-lin/p/6426925.html

  • 相关阅读:
    codeforces242E XOR on Segment
    HDU3037 Saving Beans
    BZOJ1951 [Sdoi2010]古代猪文
    BZOJ3563 DZY Loves Chinese
    HDU1573 X问题
    POJ2891 Strange Way to Express Integers
    BZOJ2152 聪聪可可
    codeforces291E Tree-String Problem
    codeforces741D Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths
    codeforces246E Blood Cousins Return
  • 原文地址:https://www.cnblogs.com/chenggege/p/7793782.html
Copyright © 2020-2023  润新知