zoukankan      html  css  js  c++  java
  • [ 总结 ] nginx 安装过程

    本次安装使用源码编译安装:

        在安装nginx之前需要先安装三个源码包:pcre、zilb、openssl
        pcre:用于rewrite重写
        zlib: 用于gzip压缩
        openssl: 主要用于https加密

    在编译安装之前一定要确保gcc等开发环境安装完成。

    # yum install gcc* -y 

    1.安装pcre   

    # cd /usr/local/src/
    # wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.37.tar.gz
    # tar xf pcre-8.37.tar.gz
    # cd pcre-8.37
    # ./configure --prefix=/usr/local/pcre-8.37
    # make && make install

    2.安装zlib

    # cd /usr/local/src/
    # wget http://zlib.net/zlib-1.2.8.tar.gz
    # tar xf zlib-1.2.8.tar.gz
    # cd zlib-1.2.8
    # ./configure --prefix=/usr/local/zlib-1.2.8
    # make && make install

    3.安装openssl

    # cd /usr/local/src/
    # wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
    # tar xf openssl-1.0.1c.tar.gz
    # cd openssl-1.0.1c
    # ./config --prefix=/usr/local/openssl-1.0.1c
    # make && make install

    4.安装nginx

    # cd /usr/local/src/
    # wget http://mirrors.sohu.com/nginx/nginx-1.9.2.tar.gz
    # tar xf nginx-1.9.2.tar.gz
    # cd nginx-1.9.2
    # groupadd -g 800 nginx
    # useradd -u 800 -g 800 -s /sbin/nologin nginx
    
    # ./configure --prefix=/usr/local/nginx 
    > --user=nginx --group=nginx 
    > --with-http_ssl_module     
    > --with-http_gzip_static_module 
    > --with-http_addition_module 
    > --with-http_stub_status_module 
    > --with-pcre=/usr/local/src/pcre-8.37      #指向解压的源码目录
    > --with-zlib=/usr/local/src/zlib-1.2.8      #指向解压的源码目录
    > --with-openssl=/usr/local/src/openssl-1.0.1c  #指向解压的源码目录
    # make && make install

     注:编译好的nginx可以通过 /usr/local/nginx/nginx -V  (具体路径以安装的为主) 查看编译时候的参数

    Nginx编译参数解析

    –prefix #nginx安装目录,默认在/usr/local/nginx
    –pid-path #pid问件位置,默认在logs目录
    –lock-path #lock问件位置,默认在logs目录
    –with-http_ssl_module #开启HTTP SSL模块,以支持HTTPS请求。
    –with-http_dav_module #开启WebDAV扩展动作模块,可为文件和目录指定权限
    –with-http_flv_module #支持对FLV文件的拖动播放
    –with-http_realip_module #支持显示真实来源IP地址
    –with-http_gzip_static_module #预压缩文件传前检查,防止文件被重复压缩
    –with-http_stub_status_module #取得一些nginx的运行状态
    –with-mail #允许POP3/IMAP4/SMTP代理模块
    –with-mail_ssl_module #允许POP3/IMAP/SMTP可以使用SSL/TLS
    –with-pcre=../pcre-8.11 #注意是未安装的pcre路径
    –with-zlib=../zlib-1.2.5 #注意是未安装的zlib路径
    –with-debug #允许调试日志
    –http-client-body-temp-path #客户端请求临时文件路径
    –http-proxy-temp-path #设置http proxy临时文件路径
    –http-fastcgi-temp-path #设置http fastcgi临时文件路径
    –http-uwsgi-temp-path=/var/tmp/nginx/uwsgi #设置uwsgi 临时文件路径
    –http-scgi-temp-path=/var/tmp/nginx/scgi #设置scgi 临时文件路径

    启动nginx

     /usr/local/nginx/nginx #不指定配置文件地址
    
     /usr/local/nginx/nginx -c /usr/local/nginx/nginx.conf #指定配置文件地址

    停止服务

    kill `cat /usr/local/nginx/nginx.pid`
    /usr/local/nginx/sbin/nginx -s stop

    检测配置文件

    /usr/local/nginx/nginx -t

        nginx -t  检测:
            如果nginx.conf 里有写include /usr/local/nginx/vhosts/*.conf
            当vhosts/*.conf 文件不存在的时候,nginx -t 检测不报错
            当vhosts/*.conf 文件存在且为空,nginx -t 检测不报错
            当vhosts/*.conf 文件存在语法正确但配置不完整,nginx -t 检测不报错
        标准写法:/usr/local/nginx/vhosts/host.conf  这样以上问题都不存在。

    重新加载配置文件(不停止服务)

    /usr/local/nginx/nginx -s reload

    打开目录浏览功能

    location / {
    
        autoindex on;#打开目录列表
        autoindex_exact_size off; #on显示文件的确切大小,off则会用M、G等单位
        autoindex_localtime on; #显示文件服务器时间,off显示GMT时间
        root   html;
        index  index.html index.htm;
    }

    参考地址:http://www.cnblogs.com/siqi/p/3572695.html

  • 相关阅读:
    <转>jmeter(十七)目录结构
    <转>jmeter(十六)配置元件之计数器
    <转>jmeter(十五)函数助手
    电商系统处理
    小程序web-view组件
    微信小程序中target与currentTarget
    小程序中navigator和wx.navigateTo,wx.redirectTo,wx.reLaunch,wx.switchTab,wx.navigateBack的用法
    怎么设置登录名 登陆后只能看到和操作一个数据库 这个用户不能看到其他的数据库
    安装和卸载windows服务程序
    sqlserver字符串多行合并为一行
  • 原文地址:https://www.cnblogs.com/hukey/p/5239145.html
Copyright © 2011-2022 走看看