zoukankan      html  css  js  c++  java
  • 编译安装Nginx(整理)

     安装Nginx

    1)   编译安装前准备

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

    2)   安装NginxStable version:最新稳定版)

    1) 下载

    cd /usr/local/src

    wget http://nginx.org/download/nginx-1.14.0.tar.gz

    2) 解压

    tar -zxvf nginx-1.14.0.tar.gz

    3) 进入目录

    cd nginx-1.14.0/

    4) 配置

    ./configure --prefix=/usr/local/nginx --pid-path=/run/nginx.pid  --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log  --with-http_ssl_module --with-http_v2_module --with-http_stub_status_module --with-pcre

    5) 编译安装

    make && make install

    3)   创建nginx启动命令脚本

    1) vi /etc/init.d/nginx

    #! /bin/bash

    # chkconfig: - 85 15

    PATH=/usr/local/nginx

    DESC="nginx daemon"

    NAME=nginx

    DAEMON=$PATH/sbin/$NAME

    CONFIGFILE=$PATH/conf/$NAME.conf

    PIDFILE=$PATH/logs/$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() {

    $DAEMON -s stop || echo -n "nginx not running"

    }

    do_reload() {

    $DAEMON -s reload || 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

    2)设置执行权限 

    chmod a+x /etc/init.d/nginx 
    注册成服务 
    chkconfig --add nginx 
    设置开机启动 
    chkconfig nginx on 

  • 相关阅读:
    MyBatis学习之输入输出类型
    MyBatis学习之多表查询
    javascript学习之this
    Elasticsearch学习之Java操作1
    CSS学习之定位
    CSS学习之浮动
    CSS学习之盒子模型
    java学习之导出Excel
    转载:手把手教你做iOS推送
    拳头公司聊天服务架构:服务器篇
  • 原文地址:https://www.cnblogs.com/daxuan/p/9847920.html
Copyright © 2011-2022 走看看