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 

  • 相关阅读:
    来自lombok的注解(解决idea中的找不到get,set方法,找不到log的问题)
    IDL语言开发规范
    神经网络训练时出现nan错误
    Hadoop WordCount程序
    Hadoop2.4.1伪分布式安装
    Hadoop简介
    linux 安装tensorflow(gpu版本)
    高级映射,查询缓存和与spring整合
    用mybatis实现dao的编写或者实现mapper代理
    mybatis介绍与环境搭建
  • 原文地址:https://www.cnblogs.com/daxuan/p/9847920.html
Copyright © 2011-2022 走看看