zoukankan      html  css  js  c++  java
  • Openresty安装

    1.安装依赖库:

    yum install pcre-devel openssl-devel gcc curl -y

    2.编译安装openresty(默认, --prefix=/usr/local/openresty 程序会被安装到/usr/local/openresty目录):

    tar -zxvf openresty-1.13.6.2.tar.gz
    cd openresty-1.13.6.2
    ./configure
    make
    make install

    3.添加环境变量:

    echo "export PATH=$PATH:/usr/local/openresty/nginx/sbin" >> /etc/profile source /etc/profile
    source /etc/profile

    4.启动openresty:

    ./usr/local/openresty/nginx/sbin/nginx

    5.查看启动状态:

    ps -ef | grep nginx

    可以编写openresty脚本来控制启动停止等操作:

    vim /etc/init.d/openresty

    脚本内容:

    #!/bin/sh
    #
    # openresty - this script starts and stops the openresty daemin
    #
    # chkconfig:   - 85 15
    # description:  OpenResty is a full-fledged web platform that integrates  
    #        the standard Nginx core, LuaJIT, many carefully written Lua libraries, 
    #        lots of high quality 3rd-party Nginx modules, and most of their external dependencies.
    # processname: openresty
    # config:      /usr/local/openresty/nginx/conf/nginx.conf
    # pidfile:     /usr/local/openresty/nginx/logs/nginx.pid
    # Url http://www.cnblogs.com/wushuaishuai/
    # Last Updated 2018.07.15
    
    # Source function library.
    . /etc/rc.d/init.d/functions
    
    # Source networking configuration.
    . /etc/sysconfig/network
    
    # Check that networking is up.
    [ "$NETWORKING" = "no" ] && exit 0
    
    nginx="/usr/local/openresty/nginx/sbin/nginx"
    prog=$(basename $nginx)
    
    NGINX_CONF_FILE="/usr/local/openresty/nginx/conf/nginx.conf"
    NGINX_PID="/usr/local/openresty/nginx/logs/nginx.pid"
    
    [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
    
    lockfile=/var/lock/subsys/nginx
    
    start() {
        [ -x $nginx ] || exit 5
        [ -f $NGINX_CONF_FILE ] || exit 6
        echo -n $"Starting $prog: "
        daemon $nginx -c $NGINX_CONF_FILE
        retval=$?
        echo
        #service php-fpm start
        [ $retval -eq 0 ] && touch $lockfile
        return $retval
    }
    stop() {
        echo -n $"Stopping $prog: "
        $nginx -s stop
        echo_success
        retval=$?
        echo
        #service php-fpm stop
        [ $retval -eq 0 ] && rm -f $lockfile
        return $retval
    }
    
    restart() {
        stop
        start
    }
    
    reload() {
        configtest || return $?
        echo -n $"Reloading $prog: "
        $nginx -s reload
        RETVAL=$?
        echo
    }
    
    force_reload() {
        restart
    }
    
    configtest() {
      $nginx -t -c $NGINX_CONF_FILE
    }
    
    rh_status() {
        status $prog
    }
    
    rh_status_q() {
        rh_status >/dev/null 2>&1
    }
    
    case "$1" in
        start)
            rh_status_q && exit 0
            $1
            ;;
        stop)
            rh_status_q || exit 0
            $1
            ;;
        restart|configtest)
            $1
            ;;
        reload)
            rh_status_q || exit 7
            $1
            ;;
        force-reload)
            force_reload
            ;;
        status)
            rh_status
            ;;
        condrestart|try-restart)
            rh_status_q || exit 0
                ;;
        *)
            echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
            exit 2
    esac

    赋权:

    chmod u+x /etc/init.d/openresty

    启动:

    service openresty start      
    stop:停止 status:运行状态

    设置开机自启:

    cd /etc/init.d
    chkconfig --add openresty
    chkconfig openresty on
  • 相关阅读:
    微信公众号开发的时候code失效的问题
    微信公众平台测试号通过网页授权获取用户的信息
    做了一些mysql的习题 感觉用来应付面试是足够了
    springMVC在使用重定向跳转
    jsp获取标签数据
    再来一次atm机 用文本做的
    django mysql数据库配置
    django url控制器
    django初始要做的事情
    flask学习
  • 原文地址:https://www.cnblogs.com/wangfajun/p/12706801.html
Copyright © 2011-2022 走看看