• nginx二进制编译-启动脚本编写


    首先先把这个文件上传到root目录下,并解压

     #tar zxf nginx-1.11.2.tar.gz 

    写脚本

    # vi nginx-running.sh

    内容如下

    #!/bin/bash
    #chkconfig: 345 61 61          //此行的345参数表示,在哪些运行级别启动,启动序号(S61);关闭序号(K61)
    #description nginx-server-scryt              //此行必写,描述服务.
    nginx=/usr/local/nginx/sbin/nginx
    case "$1" in
            start)
                    netstat -anlpt | grep nginx
                    if [ $? -eq 0 ]
                    then
                            echo "nginx service running!"
                    else
                            echo "nginx service not running!"
                            $nginx
                    fi
            ;;
            restart)
                    $nginx -s reload
                    if [ $? -eq 0 ]
                    then
                            echo "nginx server is begin restart"
                    else
                            echo "nginx server restart"
                    fi
            ;;
            stop)
                    $nginx -s stop
                    if [ $? -eq 0 ]
                    then
                            echo "nginx server is stop"
                    else
                            echo "nginx server stop,try again"
                    fi
            ;;
            status)
                    netstat -anlpt | grep nginx
                    if [ $? -eq 0 ]
                    then
                            echo "nginx server is running!"
                    else
                            echo "nginx server is not running.try to restart"
            ;;
            *)
                    echo "Please enter (start | restart | stop | status)"
            ;;
    esac
    exit 0

     安装编译环境(可省略,一般都自带编译环境)

    # yum -y groupinstall "Development Tools" "Server Platform Development"

    rpm安装两个rpm包

    # rpm -ivh /opt/dvd/Packages/zlib-devel-1.2.7-13.el7.x86_64.rpm

    # rpm -ivh /opt/dvd/Packages/pcre-devel-8.32-12.el7.x86_64.rpm 

    添加一个nginx用户

    # useradd -s /sbin/nologin -M nginx

    # id nginx

     #cd nginx-1.11.2

    # ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx

    #make

    #make install

    # cd /usr/local/nginx/sbin/

    # /usr/local/nginx/sbin/nginx 

    # ps aux | grep nginx

     

    添加80端口

    # ss -tanml | grep 80

     # cp nginx-running.sh nginx

    # cp nginx /etc/init.d/

    # cd /etc/init.d/

    # chkconfig --add nginx

    # chkconfig --list nginx

    如果是关着的则用

    #chkconfig nginx on

    关闭防火墙打开网页

  • 相关阅读:
    假期实践
    每周更新学习进度表
    作业三
    作业一
    作业二
    真实感海洋的绘制(一):基于统计学模型的水面模拟方法
    递推方程的求解
    真实感海洋的绘制(二):使用快速傅里叶变换加速波形计算
    "Mathematical Analysis of Algorithms" 阅读心得
    HTML2
  • 原文地址:https://www.cnblogs.com/djlsunshine/p/9713521.html
Copyright © 2020-2023  润新知