Nginx 安装

快速安装

Ngnix官网地址:http://nginx.org/
使用OpenResty对Nginx实现扩展。https://openresty.org/cn/
安装步骤

  1. 下载源码包,并解压。详细命令如下:
    1. wget http://nginx.org/download/nginx-1.15.3.tar.gz
    2. tar zxvf nginx-1.15.3.tar.gz
  2. 安装依赖:pcre、openssl、lua和编译工具:gcc。详细命令如下:
    1. yum install -y pcre pcre-devel
    2. yum install -y openssl openssl-devel
    3. yum install -y lua lua-devel
    4. yum install -y gcc
    5. 注:LuaJIT与Lua均可以(配置依赖分别为—with-luajit… 和—with-lua…,模块使用一致),但LuaJIT效率比Lua高。LuaJIT安装见官网:http://luajit.org/
  3. 进源码目录
  4. cd nginx-1.15.3
  5. ,配置nignx。
    1. 文档地址:http://nginx.org/en/docs/configure.html。使用./configure --help查看参数说明,翻译见:https://www.jianshu.com/p/f463d92b57b7
    2. 命令示例
    1. ./configure \
    2. --with-http_lua_module \
    3. --with-lua-lib=/usr/lib64 \
    4. --with-lua-inc=/usr/include \
    5. --with-stream \
    6. --with-stream_ssl_module
    1. 注:yum 安装默认在/usr/lib64 和/usr/include,可以使用 rpm -ql pcre-develrpm -ql lua-devel 查看相关文件。
    2. 运行结果示例:
      1. Configuration summary
      2. + using system PCRE library
      3. + using system OpenSSL library
      4. + using system zlib library
      5. nginx path prefix: "/usr/local/nginx"
      6. nginx binary file: "/usr/local/nginx/sbin/nginx"
      7. nginx modules path: "/usr/local/nginx/modules"
      8. nginx configuration prefix: "/usr/local/nginx/conf"
      9. nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
      10. nginx pid file: "/usr/local/nginx/logs/nginx.pid"
      11. nginx error log file: "/usr/local/nginx/logs/error.log"
      12. nginx http access log file: "/usr/local/nginx/logs/access.log"
      13. nginx http client request body temporary files: "client_body_temp"
      14. nginx http proxy temporary files: "proxy_temp"
      15. nginx http fastcgi temporary files: "fastcgi_temp"
      16. nginx http uwsgi temporary files: "uwsgi_temp"
      17. nginx http scgi temporary files: "scgi_temp"
  6. 编译并安装。

    1. make
    2. make install