zoukankan      html  css  js  c++  java
  • centOS下安装nginx

    1、安装pcre-8.41

      tar -xvf pcre-8.4.1.tar.gz

      cd pcre-8.4.1

      ./configure

      make && make install

    2、安装zlib-1.2.11

    3、安装nginx

      tar -xvf nginx-1.12.2.tar.gz

      cd nginx-1.12.2

      ./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-pcre=../pcre-8.41 --with-zlib=../zlib-1.2.11

      make && make install

    4、nginx开机自启动

    4.1 vim /etc/init.d/nginx  (红色两行一定要添加)

    #! /bin/sh

     

    # chkconfig: - 85 15
    # description: nginx is a World Wide Web server. It is used to serve

    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

    DESC="nginx daemon"
    NAME=nginx
    DAEMON=/usr/local/nginx/$NAME
    CONFIGFILE=/usr/local/nginx/$NAME.conf
    PIDFILE=/usr/local/nginx/$NAME.pid
    SCRIPTNAME=/etc/init.d/$NAME

    set -e
    [ -x "$DAEMON" ] || exit 0

    do_start() {
    $DAEMON -c $CONFIGFILE || echo -n "nginx already running"
    }

    do_stop() {
    kill -INT `cat $PIDFILE` || echo -n "nginx not running"
    }

    do_reload() {
    kill -HUP `cat $PIDFILE` || echo -n "nginx can't reload"
    }

    case "$1" in
    start)
    echo -n "Starting $DESC: $NAME"
    do_start
    echo "."
    ;;
    stop)
    echo -n "Stopping $DESC: $NAME"
    do_stop
    echo "."
    ;;
    reload|graceful)
    echo -n "Reloading $DESC configuration..."
    do_reload
    echo "."
    ;;
    restart)
    echo -n "Restarting $DESC: $NAME"
    do_stop
    do_start
    echo "."
    ;;
    *)
    echo "Usage: $SCRIPTNAME {start|stop|reload|restart}" >&2
    exit 3
    ;;
    esac

    exit 0

        chkconfig --add nginx

     chkconfig nginx on

    至此,开机启动配置完成

  • 相关阅读:
    md5
    表空间
    create_index
    非额度合同和额度合同
    如何在linux中查找python安装包的路径
    Golang中的SingleFlight与CyclicBarrier
    linux安装protoc
    protobuf 的优缺点
    Xshell 连接 VirtualBox
    限制 input 输入框只能输入纯数字
  • 原文地址:https://www.cnblogs.com/bury12/p/8048175.html
Copyright © 2011-2022 走看看