• php扩展redis,编译安装redis服务


    首先安装redis扩展
    
    https://github.com/phpredis/phpredis
    下载
    http://redis.io/download 服务软件

    cd到软件存放目录
    unzip phpredis-master.zip
    cd
    phpredis-master
    /usr/local/php/bin/phpize
    ./configure --with-php-config=/usr/local/php/bin/php-config
     make
    make install
    会得到
    /usr/local/php/lib/php/extensions/no-debug-zts-20131226/redis.so

    cp php.ini-production /etc/php.ini这个是配置文件路径
    如果你没有在编译的时候指定php的配置文件的路径,默认是/etc/下面
    如果你不知道在哪,phpinfo的信息

    Configuration File (php.ini) Path /etc
    Loaded Configuration File /etc/php.ini

    vi
    /etc/php.ini
    加一句
    extension=redis.so

    重启nginx服务器和php-fpm

    /usr/local/php/bin/php -m查看加载了redis模块

    安装redis-server
    tar -zxvf redis-2.8.19.tar.gz
    cd redis-2.8.19
    新版的貌似不能./configure --prefix=路径了
    make
    make install


    cp redis.conf  /etc/
    redis-server /etc/redis.conf
    是前台运行,启动要改为后台运行

    vi /etc/redis.conf

    daemonize yes



    /usr/local/src/redis/utils/redis_init_script  是脚本文件

    现在把redis做为服务

    ls

    mkdir /etc/redis/

    做为配置文件的路径

    cp /usr/local/src/redis-2.8.19/utils/redis_init_script /etc/rc.d/init.d/redis

    chkconfig --add redis

    加入服务失败

    vi /etc/rc.d/init.d/redis  

    #!/bin/bash  
    #chkconfig: 2345 80 90  
    # Simple Redis init.d script conceived to work on Linux systems  
    # as it does use of the /proc filesystem.  
      
    REDISPORT=6379  
    EXEC=/usr/local/redis/bin/redis-server  
    CLIEXEC=/usr/local/redis/bin/redis-cli  
      
    PIDFILE=/var/run/redis_${REDISPORT}.pid  
    CONF="/etc/redis/${REDISPORT}.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  

    这个是修改好的配置文件

     原文件是没有以下第2行的内容的, 

    引用
    #chkconfig: 2345 80 90
     
    更改redis开启的命令,以后台运行的方式执行: 
      
    Java代码 

    $EXEC $CONF & 

    cp /usr/local/src/redis-2.8.19/redis.conf /etc/redis/6379.conf  

    chkconfig --add redis 

    chkconfig redis on

    service redis start

    redis-cli

    vi /etc/redis/6379.conf

    daemonize yes

    就oK,查看redis服务是不是启动

    netstat -tnlp

    就OK了






     
  • 相关阅读:
    win查看所有wifi密码
    vsftp配置详解
    python3.7项目打包为一个exe
    ATT&CK实战系列——红队实战(一)
    PHP SECURITY CALENDAR 2017 (Day 9
    python3安装gmpy2
    [CISCN2019 总决赛 Day2 Web1]Easyweb(预期解)
    python2与python3共存及py2IDLE打不开的解决方案
    [BJDCTF 2nd]
    PHP SECURITY CALENDAR 2017 (Day 1
  • 原文地址:https://www.cnblogs.com/zx-admin/p/4316045.html
Copyright © 2020-2023  润新知