美文网首页
Redis安装

Redis安装

作者: 爱折腾的傻小子 | 来源:发表于2018-10-29 11:08 被阅读3次

    Redis | phpredis

    • 注意安装redis php扩展时,由于使用的是php7版本所以当前文档提供的版本需要替换为:phpredis - php7 | (使用这个版本进行安装)
    Redis 守护进程linux开机自启

    redis启动 | (注意文档中存在错误 脚本代码需要加上开头项 #!/bin/sh )

    #!/bin/sh 
    
    # chkconfig:   2345 90 10
    # description:  Redis is a persistent key-value database
    
    PATH=/usr/local/src/redis/src
    REDISPORT=6379
    EXEC=/usr/local/src/redis/src/redis-server
    REDIS_CLI=/usr/local/src/redis/src/redis-cli
    #Redis密码
    PASSWORD=bmS123456
    PIDFILE=/var/run/redis.pid
    CONF="/usr/local/src/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 -a $PASSWORD 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安装

          本文链接:https://www.haomeiwen.com/subject/dyhkdxtx.html