zoukankan      html  css  js  c++  java
  • nginx安装过程

    安装环境准备
     
    1、GCC编译器
      yum install gcc
      apt-get install gcc
     
    2、PCRE library(PERL兼容正则表达式),用于支持正则式
      pcre  提供静态或者动态库
      pcre-devel  提供开发头文件和源码    
      yum install pcre pcre-devel
      apt-get install libpcre3 libpcre3-dev 
     
    3、zlib library(gzip压缩库,用于http返回压缩使用)
      yum install zlib zlib-devel
      apt-get install zlib1g zlib1g-dev
     
    4、OpenSSL(只有使用https时才需要)
      yum install openssl openssl-devel
      apt-get install openssl openssl-dev
     
    下载代码和安装
     
    1、下载源码
     
    2、解压源码
      tar zxvf nginx-1.6.0.tar.gz
      cd nginx-1.6.0
     
    3、安装配置
      ./configure --help:查看可选配置项
      ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx-1.6.0
     
    4、编译与安装
      make
      make install
     
    5、检查配置文件及启动
      sudo /usr/local/nginx-1.6.0/sbin/nginx -t     检查配置文件是否正确
      sudo /usr/local/nginx-1.6.0/sbin/nginx
      sudo netstat -npl | grep nginx     检查端口是否启动成功 
      curl http://localhost/     检查http请求是否正常
     
    6、停止、重启、重新加载nginx
      sudo /usr/local/nginx-1.6.0/sbin/nginx -s stop     马上停止nginx
      sudo /usr/local/nginx-1.6.0/sbin/nginx -s quit       从容停止nginx,等待已有请求结束
      sudo /usr/local/nginx-1.6.0/sbin/nginx -s reopen    从新打开日志文件
      sudo /usr/local/nginx-1.6.0/sbin/nginx -s reload     从新加载配置文件
     
      异常停止
      kill -9 nginxpid
      killall nginx
     
    7、编辑nginx启动服务脚本/etc/init.d/nginx
    #! /bin/sh
    # Author: Ryan Norbauer http://norbauerinc.com
    # Modified: Geoffrey Grosenbach http://topfunky.com
    # Modified: Clement NEDELCU
    # Reproduced with express authorization from its contributors
     
    set –e
    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
    DESC="nginx daemon"
    NAME=nginx
    DAEMON=/usr/local/nginx-1.6.0/sbin/$NAME
    SCRIPTNAME=/etc/init.d/$NAME
     
    # If the daemon file is not found, terminate the script.
    test -x $DAEMON || exit 0
     
    d_start() {
        $DAEMON || echo -n " already running"
    }
    
    d_stop() {
        $DAEMON –s quit || echo -n " not running"
    }
    
    d_reload() {
        $DAEMON –s reload || echo -n " could not reload"
    }
    
    case "$1" in
        start)
            echo -n "Starting $DESC: $NAME"
            d_start
           echo "."
        ;;
        stop)
           echo -n "Stopping $DESC: $NAME"
           d_stop
           echo "."
        ;;
        reload)
           echo -n "Reloading $DESC configuration..."
           d_reload
           echo "reloaded."
        ;;
        restart)
           echo -n "Restarting $DESC: $NAME"
           d_stop
           # Sleep for two seconds before starting again, this should give the
           # Nginx daemon some time to perform a graceful stop.
           sleep 2
           d_start
           echo "."
        ;;
        *)
           echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2
           exit 3
        ;;
    esac
    exit 0

     

    8、修改nginx启动服务脚本权限
      sudo chomd a+x /etc/init.d/nginx
     
    9、启动、关闭、重新加载nginx服务
      service nginx start
      service nginx stop
      service nginx reopen
      service nginx reload
     
    10、安装nginx服务
      update-rc.d -f nginx defaults     debian系列
      chkconfig --add nginx     red-hat系列
     
     
     
        
     
     
        
        
     
     
        
        
  • 相关阅读:
    《拼音字母》 蓝桥杯复试试题
    ZT:成熟是一种明亮而不刺眼的光辉
    如何Enable FireFox里的Java Plugin
    将App发布到WasLiberty的较稳妥方法
    记一个发HTML格式邮件的问题
    有些工作,做一辈子也不会成功
    论本事
    又一次遇到Data truncation: Data too longData truncation: Data too long问题
    查看Linux上MySQL版本信息
    很多人终身一事无成
  • 原文地址:https://www.cnblogs.com/deacon/p/4313875.html
Copyright © 2011-2022 走看看