OpenResty安装部署

Nginx安装部署文档

注意: nginx安装不允许安装官网下载的版本, 一律安装openresty。安装目录必须是 /usr/servers ,数据、日志、缓存目录必须是 /data 目录

  1. 首先安装perl环境,自己百度

  2. 安装openresty,安装包官网下载即可 openresty

    分别执行以下命令安装

    mkdir -p /usr/servers && cd /usr/servers
    
    yum install -y pcre-devel openssl-devel gcc curl
    
    tar -xzvf openresty-1.15.8.2.tar.gz
    
    cd /usr/servers/openresty-1.15.8.2/
    
    chmod 777 ./configure
    
    ./configure --prefix=/usr/servers --add-module=/usr/servers/openresty-1.19.9.1/lib/lua-upstream-nginx-module -j2
    
    # 如果报错,则在 configure 的时候带上以下参数  --with-openssl=/usr/servers/openssl-1.0.2k
    # 通过以下命令查询物理CPU个数: cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l
    # 如果物理cpu为2个,则使用 make -j2
    # 最后执行
    make install
    
  3. 启动openresty

    /usr/servers/nginx/sbin/nginx
    
  4. 修改操作系统内核参数 sysctl.conf

    vim /etc/sysctl.conf
    
    # 添加以下配置项
    
    * soft  core   unlimit
    * hard  core   unlimit
    * soft  fsize  unlimited
    * hard  fsize  unlimited
    * soft  data   unlimited
    * hard  data   unlimited
    * soft  nproc  65535
    * hard  nproc  63535
    * soft  stack  unlimited
    * hard  stack  unlimited
    * soft  nofile  409600
    * hard  nofile  409600
    
  5. 在 /usr/servers 目录建立工程化目录,比如畅游公园, 参考模板 bjgyol 目录 bjgyol bjgyol.conf lua bjgyol.lua lualib *.lua *.so

  6. 添加nginx配置, 加入畅游公园工程

    http {
      include           mime.types;
      default_type      text/html;
      lua_package_path  "/usr/servers/bjgyol/lualib/?.lua;;";
      lua_package_cpath "/usr/servers/bjgyol/lualib/?.so;;";
      include           /usr/servers/bjgyol/bjgyol.conf;
    }
    
  7. 配置开机启动

    # 添加 nginx.service 文件
    vim /usr/lib/systemd/system/nginx.service
    
    [Unit]
    Description=The NGINX HTTP and reverse proxy server
    
    [Service]
    Type=forking
    ExecStartPre=/usr/servers/nginx/sbin/nginx -c /usr/servers/nginx/conf/nginx.conf -t
    ExecStart=/usr/servers/nginx/sbin/nginx -c /usr/servers/nginx/conf/nginx.conf
    ExecReload=/bin/kill -s HUP $MAINPID
    ExecStop=/bin/kill -s QUIT $MAINPID
    PrivateTmp=true
    
    [Install]
    WantedBy=multi-user.target
    
    # 执行命令, 配置开机启动
    systemctl daemon-reload
    systemctl enable nginx
    
  8. 安装完成配置参考 - 以下配置为完整的畅游公园配置

    nginx.conf 配置参考

    cache.lua 配置参考

    delcache.lua 配置参考

  9. 详细配置参考

    # nginx.conf 文件,仅供参考
    user root;
    # 去掉后台启动, 调试模式使用
    daemon off;
    # 记录错误日志到标准输出设备, 调试模式下使用
    error_log /dev/stdout debug;
    
    # 工作进程数
    worker_processes auto;
    worker_rlimit_nofile 102400;
    # CPU亲和性, 如果 CPU 核心数量为 4 则修改为 worker_cpu_affinity 0001 0010 0100 1000;
    worker_cpu_affinity 0000000000000001 0000000000000010 0000000000000100 0000000000001000 0000000000010000 0000000000100000 0000000001000000 0000000010000000 0000000100000000 0000001000000000 0000010000000000 0000100000000000 0001000000000000 0010000000000000 0100000000000000 1000000000000000;
    
    events {
        use epoll;
        worker_connections 102400;
        multi_accept on;
    }
    
    http {
        # 打开或关闭错误页面中的nginx版本号等信息
        server_tokens off;
        include mime.types;
        default_type application/octet-stream;
    	# 添加 skywalking 链路监控功能
        lua_package_path "/usr/servers/skywalking-nginx-lua-0.6.0/lib/?.lua;;";
        lua_shared_dict tracing_buffer 100m;
    
        init_worker_by_lua_block {
          local metadata_buffer = ngx.shared.tracing_buffer
          metadata_buffer:set('serviceName', 'nginx-tracing-service')
          metadata_buffer:set('serviceInstanceName', 'nginx-tracing-service')
          metadata_buffer:set('includeHostInEntrySpan', true)
          require("skywalking.util").set_randomseed()
          require("skywalking.client"):startBackendTimer("http://10.2.9.150:12800")
        }
    
        # 本地缓存
        lua_shared_dict my_req_store 150m;
        lua_shared_dict my_conn_store 150m;
        lua_shared_dict my_cache 300m;
    
        # 记录
        # 连接序列号(connection), 客户端IP(remote_addr), 客户端用户名称(remote_user)
        # 本地时间(time_local), 完整的原始请求行(request), 响应状态码(status), 发送给客户端的字节数(body_bytes_sent)
        # 请求的referer地址(http_referer), 客户端浏览器信息(http_user_agent)
        # 当前端有代理服务器时,设置web节点记录客户端地址的配置,此参数生效的前提是代理服务器也要进行相关的x_forwarded_for设置 (http_x_forwarded_for)
        # 上游应用地址(upstream_addr), 上游应用返回状态(upstream_status)
        log_format main '$connection $remote_addr - $remote_user [$time_local] "$request" $status - $body_bytes_sent "$http_referer" [$http_user_agent] "$http_x_forwarded_for" | [$upstream_addr $upstream_status]';
    
        # 错误日志输出及错误日志级别
        error_log /data/logs/error.log error;
        # 访问日志输出及访问日志级别,mainlog_format中定义
        access_log /data/logs/access.log main;
    
        # 优化磁盘IO设置,指定nginx是否调用sendfile函数来输出文件,普通应用设为on,下载等磁盘IO高的应用,可设为off
        sendfile                            on;
        # 减少网络报文段数量, 提高I/O性能
        # 缓存发送请求,启用如下两个配置,会在数据包达到一定大小后再发送数据
        # 这样会减少网络通信次数,降低阻塞概率,但也会影响响应的及时性
        # 比较适合于文件下载这类的大数据包通信场景
        # tcp_nopush                          on;
        # tcp_nodelay                         on;
        # 为给定的key设置最大的连接数,这里的keyaddr,设定的值是100,就是说允许每一个IP地址最多同时打开100个连接
        # limit_conn addr 100;
        keepalive_timeout                   30;
        port_in_redirect                    off;
        # 允许客户端请求的最大单文件字节数
        client_max_body_size                4m;
        # 客户端请求头缓冲区大小
        client_header_buffer_size           4k;
        client_body_buffer_size             512k;
        # 静态文件缓存
        # 开启缓存的同时也指定了缓存文件的最大数量,20s如果文件没有被请求则删除缓存
        open_file_cache                     max=102400 inactive=20s;
        # 多长时间检查一次缓存的有效期
        open_file_cache_valid               30s;
        # 有效期内缓存文件最小的访问次数,只有访问超过2次的才会被缓存
        open_file_cache_min_uses            2;
    
        client_header_timeout               15;
        client_body_timeout                 15;
        reset_timedout_connection           on;
        send_timeout                        15;
        # FastCGI相关参数是为了改善网站的性能:减少资源占用,提高访问速度
        # Nginx服务器和后端FastCGI服务器连接的超时时间
        fastcgi_connect_timeout             240;
        # Nginx允许FastCGI服务器返回数据的超时时间,即在规定时间内后端服务器必须传完所有的数据,否则Nginx将断开这个连接
        fastcgi_send_timeout                240;
        # NginxFastCGI服务器读取响应信息的超时时间,表示连接建立成功后,Nginx等待后端服务器的响应时间
        fastcgi_read_timeout                240;
        # Nginx FastCGI 的缓冲区大小,用来读取从FastCGI服务器端收到的第一部分响应信息的缓冲区大小
        fastcgi_buffer_size                 64k;
        # 设定用来读取从FastCGI服务器端收到的响应信息的缓冲区大小和缓冲区数量
        fastcgi_buffers                     4 64k;
        # 用于设置系统很忙时可以使用的 proxy_buffers 大小
        fastcgi_busy_buffers_size           128k;
        # FastCGI 临时文件的大小
        fastcgi_temp_file_write_size        128k;
        # FastCGI 临时文件的存放路径
        # fastcti_temp_path                   /data/ngx_fcgi_tmp;
        # 缓存目录
        fastcgi_cache_path                  /data/ngx_fcgi_cache levels=2:2 keys_zone=ngx_fcgi_cache:512m inactive=1d max_size=40g;
        # gzip配置
        gzip                                on;
        gzip_min_length                     8k;
        gzip_buffers                        4 32k;
        gzip_http_version                   1.1;
        gzip_comp_level                     2;
        gzip_types                          text/plain text/css text/javascript application/json application/javascript  application/x-javascript application/xml image/gif image/jpeg image/png;
        gzip_vary                           on;
        gzip_proxied                        any;
        gzip_disable                        msie6;
        # 反向代理配置, nginx跟后端服务器连接超时时间(代理连接超时)
        proxy_connect_timeout               60;
        # 连接成功后,后端服务器响应时间(代理接收超时)
        proxy_send_timeout                  60;
        # 连接成功后,后端服务器响应时间(代理接收超时)
        proxy_read_timeout                  60;
        # 设置代理服务器(nginx)保存用户头信息的缓冲区大小
        proxy_buffer_size                   32k;
        # proxy_buffers缓冲区,网页平均在32k以下的设置
        proxy_buffers                       4 128k;
        # 高负荷下缓冲大小(proxy_buffers*2
        proxy_busy_buffers_size             256k;
        # 设定缓存文件夹大小,大于这个值,将从upstream服务器传
        proxy_temp_file_write_size          256k;
        # 反向代理缓存目录及缓存大小配置
        proxy_temp_path                     /data/proxy_temp;
        proxy_cache_path                    /data/proxy_cache levels=1:2 keys_zone=cache_one:100m inactive=7d max_size=10g;
    
        upstream web_app_api {
            server 192.159.51.2:60001;
            server 192.159.51.3:60001;
            server 192.159.51.5:60001;
            server 192.159.51.6:60001;
            server 192.159.51.7:60001;
            server 192.159.51.8:60001;
        }
    
        #PC
        server {
            listen 80;
            server_name www.bjgyol.com.cn bjgyol.com.cn;
    
            # 错误日志输出及错误日志级别
            error_log /data/logs/error_bjgyol.com.cn.log error;
            # 访问日志输出及访问日志级别,mainlog_format中定义
            access_log /data/logs/access_bjgyol.com.cn.log main;
    
            add_header X-Frame-Options SAMEORIGIN;
            add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; ";
    
            if ($http_x_forwarded_for ~* (123.7.114.128|114.242.250.103|153.37.196.2|1.180.210.101|58.209.170.8)) {
                return 503;
            }
    
            if ($http_referer ~* ^.*\[bendibao\].*$) {
                return 503;
            }
    
            # PC端访问,限制各种爬虫工具爬
            if ($http_user_agent ~* "scrapy|python|wget") {
                return 503;
            }
    
            location / {
                # 限源, 配置只这些ip访问
                #if ($http_x_forwarded_for !~* "106.121.136.233|106.121.137.138|223.223.204.220") {
                #   return 403;
                #}
    
                # 静态文件不记录日志,提高访问性能
                access_log off;
    
                if ($request_filename ~* .*\.(?:htm|html)$) {
                    add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate";
                }
    
                if ($request_filename ~* .*\.(?:js|css)$) {
                    expires 365d;
                }
    
                if ($request_filename ~* .*\.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm)$) {
                    expires 365d;
                }
    
                root /data/bjgyol/pc_new;
                index index.html index.htm;
                error_page 405 =200 http://$host$request_uri;
                #error_page 403 /403.html;
            }
    
            location ~* ^/api-.*/ {
                # 添加 skywaking 上报
                rewrite_by_lua_block {
                  require("skywalking.tracer"):start("nginx tracing service")
                }
                body_filter_by_lua_block {
                  if ngx.arg[2] then
                    require("skywalking.tracer"):finish()
                  end
                }
                log_by_lua_block {
                  require("skywalking.tracer"):prepareForReport()
                }
                lua_code_cache on;
                default_type "application/json";
                access_by_lua_file /usr/servers/bjgyol/lua/cache.lua;
                proxy_next_upstream http_502 http_504 error timeout invalid_header;
                proxy_set_header Host  $host;
                proxy_set_header Cookie $http_cookie;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_pass http://web_app_api;
            }
    
            location /delcache {
                lua_code_cache on;
                default_type "application/json";
                access_by_lua_file /usr/servers/bjgyol/lua/delcache.lua;
            }
        }
    }
    
    -- 配置文件中涉及到的 LUA 脚本, 仅供参考
    
    -- 获取Nginx字典中的缓存数据
    local function get_from_cache(key)
        local cache_ngx = ngx.shared.my_cache
        local value = cache_ngx:get(key)
        return value
    end
    
    -- 将Nginx字典中的缓存赋值
    local function set_to_cache(key,value,exptime)
        if not exptime then
            exptime = 10 * 60
        end
        local cache_ngx = ngx.shared.my_cache
        local succ,err,forcible = cache_ngx:set(key,value,exptime)
        return succ
    end
    
    -- 获取请求路径
    local req_uri = ngx.var.request_uri
    local path = req_uri:match("(.*)?")
    local last_path = req_uri:match("?(.*)")
    -- 公园首页
    if path == "/api-cache/anno/index" then
        local args = ngx.req.get_uri_args()
        -- ngx.log(ngx.INFO,"进入到公园首页")
        local tp = tostring(args["type"])
        if tp == "" or tp == nil then
            return nil
        end
        -- 从Nginx缓存中获取数据
        local index_model = get_from_cache("index_"..tp)
    
        -- 如果Nginx缓存中数据为空则发送http请求获取数据
        if index_model == nil or index_model == "" then
     	-- ngx.log(ngx.ERR,"首页无本地缓存")
            local zhttp = require "resty.http"
            local httpc = zhttp.new()
            local resp, err = httpc:request_uri("http://192.159.51.2:60001",{
                method = "GET",
                path = req_uri,
                --headers = {
                --    ["Content-Type"] = "application/json",
                --},
                -- 需要显示指定keepalive,否则openstry在http执行会报错
                keepalive = false
            })
            index_model = resp.body
           --  ngx.log(ngx.INFO,"Nginx中没有【首页】缓存,从API接口调用获取,参数为:"..tp.."内容:"..index_model)
            -- 将查询到的数据放到缓存中,缓存时间为60S
            set_to_cache("index_"..tp,index_model,10*60)
        end
        -- ngx.log(ngx.ERR,"首页有缓存")
        -- 输出
        ngx.say(index_model)
        return ngx.exit(ngx.HTTP_OK)
    -- 公园提示信息页
    elseif path == "/api-cache/anno/category_warning" then
        local args = ngx.req.get_uri_args()
        local category_id = tostring(args["categoryId"])
        if category_id == "" or category_id == nil then
            return nil
        end
        -- 从Nginx缓存中获取数据
        local category_warning_model = get_from_cache("category_warning_"..category_id)
        -- 如果Nginx缓存中数据为空则发送http请求获取数据
        if category_warning_model == nil or category_warning_model == "" then
            local zhttp = require "resty.http"
            local httpc = zhttp.new()
            local resp, err = httpc:request_uri("http://192.159.51.2:60001",{
                method = "GET",
                path = req_uri,
                headers = {
                    ["Content-Type"] = "application/json",
                },
                -- 需要显示指定keepalive,否则openstry在http执行会报错
                keepalive = false
            })
            category_warning_model = resp.body
            --将查询到的数据放到缓存中,缓存时间为60S
            set_to_cache("category_warning_"..category_id,category_warning_model,10*60)
        end
        -- 输出
        ngx.say(category_warning_model)
        return ngx.exit(ngx.HTTP_OK)
    -- 公园详情页
    elseif path == "/api-cache/anno/index/category" then
        local args = ngx.req.get_uri_args()
        local category_id = tostring(args["categoryId"])
        local tp = tostring(args["type"])
        if category_id == "" or category_id == nil then
            return nil
        end
        -- 从Nginx缓存中获取数据
        local category_detail_model = get_from_cache("category_detail_"..tp..category_id)
        -- 如果Nginx缓存中数据为空则发送http请求获取数据
        if category_detail_model == nil or category_detail_model == "" then
            local zhttp = require "resty.http"
            local httpc = zhttp.new()
            local resp, err = httpc:request_uri("http://192.159.51.2:60001",{
                method = "GET",
                path = req_uri,
                headers = {
                    ["Content-Type"] = "application/json",
                },
                -- 需要显示指定keepalive,否则openstry在http执行会报错
                keepalive = false
            })
            category_detail_model = resp.body
            --将查询到的数据放到缓存中,缓存时间为60S
            set_to_cache("category_detail_"..tp..category_id,category_detail_model,10*60)
        end
        -- 输出
        ngx.say(category_detail_model)
        return ngx.exit(ngx.HTTP_OK)
    -- 公园商品票详情页
    elseif path == "/api-cache/anno/index/category/product" then
        local args = ngx.req.get_uri_args()
        local sku_id = tostring(args["skuId"])
        local tp = tostring(args["type"])
        if sku_id == "" or sku_id == nil then
            return nil
        end
        -- 从Nginx缓存中获取数据
        local product_detail_model = get_from_cache("product_detail_"..tp..sku_id)
        -- 如果Nginx缓存中数据为空则发送http请求获取数据
        if product_detail_model == nil or product_detail_model == "" then
            local zhttp = require "resty.http"
            local httpc = zhttp.new()
            local resp, err = httpc:request_uri("http://192.159.51.2:60001",{
                method = "GET",
                path = req_uri,
                -- 需要显示指定keepalive,否则openstry在http执行会报错
                keepalive = false
            })
            product_detail_model = resp.body
            -- 将查询到的数据放到缓存中,缓存时间为60S
            set_to_cache("product_detail_"..tp..sku_id,product_detail_model,10*60)
        end
        -- 输出
        ngx.say(product_detail_model)
        return ngx.exit(ngx.HTTP_OK)
    else
        return
    end                   
    
  10. 所有编译参数解释

    # ./configure 参数详解
    --prefix=PATH                      # set the installation prefix (default to /usr/local/openresty)
    --with-debug                       # enable debug logging
    --with-no-pool-patch               # enable the no-pool patch for debugging memory issues
    -jN                                # pass -jN option to make while building LuaJIT 2.1
    --without-http_echo_module         # 不编译可以在 Nginx 的 URL 访问中通过 echo 命令输出字符到用户的浏览器,一般用来调试输出信息,检测 Nginx 的可访问性、配置正确性
    --without-http_xss_module          # 不编译跨站点脚本支持, 该模块提供了跨站点 AJAX 支持,目前只支持跨站点的 GET 方法
    --without-http_coolkit_module      # 不编译 Nginx 插件模块集合
    --without-http_set_misc_module     # 不编译 rewrite 指令的扩展, 该模块是 Nginx 的 rewrite 模块的功能增强模块,提供了更多的指令
    
    --without-http_form_input_module   disable ngx_http_form_input_module # 不编译 HTTP 请求扩展
    --without-http_encrypted_session_module disable ngx_http_encrypted_session_module # 不编译加密解密 Nginx 变量值的模块
    --without-http_srcache_module      disable ngx_http_srcache_module # 不编译缓存增强模块, 该模块为 Nginx 提供了一个透明的缓存层,可以用在 Nginx 的任意位置
    
    --without-http_lua_module          disable ngx_http_lua_module # 不编译 Lua 脚本支持模块
    --without-http_lua_upstream_module disable ngx_http_lua_upstream_module # 不编译提供操作 upstream 服务器 Lua API 功能的模块
    --without-http_headers_more_module disable ngx_http_headers_more_module # 不编译 header 返回信息编辑模块
    --without-http_array_var_module    disable ngx_http_array_var_module # 不编译数组类型的 Nginx 变量模块
    --without-http_memc_module         disable ngx_http_memc_module # 不编译 Memcache 扩展模块
    --without-http_redis2_module       disable ngx_http_redis2_module # 不编译 Redis 2.0 协议支持模块
    --without-http_redis_module        disable ngx_http_redis_module # 不编译 Redis 缓存的模块
    --without-http_rds_json_module     disable ngx_http_rds_json_module # 不编译 DBD-Stream 格式转 JSON 格式模块
    --without-http_rds_csv_module      disable ngx_http_rds_csv_module # 不编译 DBD-Stream 格式转 cvs 格式模块
    --without-stream_lua_module        disable ngx_stream_lua_module # 不编译 TCP/UDP 负载 Lua 脚本支持模块
    --without-ngx_devel_kit_module     disable ngx_devel_kit_module # 不编译模块开发库
    --without-stream                   disable TCP/UDP proxy module
    --without-http_ssl_module          disable ngx_http_ssl_module # 不编译 HTTP SSL 支持模块
    --without-stream_ssl_module        disable ngx_stream_ssl_module # 不编译 Stream SSL 支持模块
    
    --with-http_iconv_module           enable ngx_http_iconv_module # 编译编码字符转换模块
    --with-http_drizzle_module         enable ngx_http_drizzle_module # 编译 MySQL 或 Drizzle 数据库访问模块
    --with-http_postgres_module        enable ngx_http_postgres_module # 编译 PostgreSQL 数据库访问模块
    
    --without-lua_cjson                disable the lua-cjson library # 不编译快速解析 JSON 的一个 Lua C 模块
    --without-lua_tablepool            disable the lua-tablepool library (and by consequence, the lua-resty-shell library) # 不编译基于 LuaJIT 的 Lua 表格资源回收池支持库
    --without-lua_redis_parser         disable the lua-redis-parser library # 不编译 Redis 数据解析为 Lua 数据结构模块
    --without-lua_rds_parser           disable the lua-rds-parser library # 不编译 DBD-Stream 格式的数据解析为 Lua 数据结构模块
    --without-lua_resty_dns            disable the lua-resty-dns library # 不编译 DNS(域名系统)解析器的 Lua 模块
    --without-lua_resty_memcached      disable the lua-resty-memcached library # 不编译 Memcached 客户端模块
    --without-lua_resty_redis          disable the lua-resty-redis library # 不编译 Redis 客户端模块
    --without-lua_resty_mysql          disable the lua-resty-mysql library # 不编译 MySQL 客户端模块
    --without-lua_resty_upload         disable the lua-resty-upload library # 不编译上传文件支持模块
    --without-lua_resty_upstream_healthcheck disable the lua-resty-upstream-healthcheck library # 不编译基于 Lua 的服务器组健康监测模块
    --without-lua_resty_string         disable the lua-resty-string library # 不编译字符串实用程序和通用哈希函数的 Lua 库
    --without-lua_resty_websocket      disable the lua-resty-websocket library # 不编译基于 Lua 的非阻塞 WebSocket 服务/客户端
    --without-lua_resty_limit_traffic  disable the lua-resty-limit-traffic library # 不编译 lua-resty-limit-traffic 支持库
    --without-lua_resty_lock           disable the lua-resty-lock library # 不编译基于 Lua Nginx 模块的共享内存字典的简单非阻塞互斥锁 API
    --without-lua_resty_lrucache       disable the lua-resty-lrucache library # 不编译 Lua-land LRU 缓存
    --without-lua_resty_signal         disable the lua-resty-signal library (and by consequence, the lua-resty-shell library) # 不编译 lua-resty-signal 支持库,该支持库用于向 UNIX 进程发送信号
    --without-lua_resty_shell          disable the lua-resty-shell library # 不编译 lua-resty-shell 支持库,该支持库可以实现通过 Lua 调用 shell 脚本的支持
    --without-lua_resty_core           disable the lua-resty-core library # 不编译使用 LuaJIT FFI 实现 Lua Nginx 模块提供的 Lua API
    
    --with-luajit=DIR                  use the external LuaJIT 2.1 installation specified by DIR # 编译 LuaJIT 2.1 解释器, 指定外部路径,默认使用内部路径
    --with-luajit-xcflags=FLAGS        Specify extra C compiler flags for LuaJIT 2.1
    --with-luajit-ldflags=FLAGS        Specify extra C linker flags for LuaJIT 2.1
    --without-luajit-lua52             Turns off the LuaJIT extensions from Lua 5.2 that may break backward compatibility # 不编译基于 Lua 5.2 的 LuaJIT 扩展解释器
    --without-luajit-gc64              Turns off the LuaJIT GC64 mode (which is enabled by default on x86_64)
    
    --with-libdrizzle=DIR              specify the libdrizzle 1.0 (or drizzle) installation prefix
    --with-libpq=DIR                   specify the libpq (or postgresql) installation prefix
    --with-pg_config=PATH              specify the path of the pg_config utility
    
    # Options directly inherited from nginx
    
    --sbin-path=PATH                   set nginx binary pathname
    --modules-path=PATH                set modules path
    --conf-path=PATH                   set nginx.conf pathname
    --error-log-path=PATH              set error log pathname
    --pid-path=PATH                    set nginx.pid pathname
    --lock-path=PATH                   set nginx.lock pathname
    
    --user=USER                        set non-privileged user for worker processes
    --group=GROUP                      set non-privileged group for worker processes
    
    --build=NAME                       set build name
    --builddir=DIR                     set build directory
    
    --with-select_module               enable select module
    --without-select_module            disable select module
    --with-poll_module                 enable poll module
    --without-poll_module              disable poll module
    
    --with-threads                     enable thread pool support
    
    --with-file-aio                    enable file AIO support
    
    --with-http_ssl_module             enable ngx_http_ssl_module (default on)
    --with-http_v2_module              enable ngx_http_v2_module
    --with-http_realip_module          enable ngx_http_realip_module                          # 获取用户真实ip模块
    --with-http_addition_module        enable ngx_http_addition_module
    --with-http_xslt_module            enable ngx_http_xslt_module
    --with-http_xslt_module=dynamic    enable dynamic ngx_http_xslt_module
    --with-http_image_filter_module    enable ngx_http_image_filter_module
    --with-http_image_filter_module=dynamic enable dynamic ngx_http_image_filter_module
    --with-http_geoip_module           enable ngx_http_geoip_module                            # 根据IP获取城市信息,经纬度信息等
    --with-http_geoip_module=dynamic   enable dynamic ngx_http_geoip_module                    # 根据IP动态获取城市信息,经纬度信息等
    --with-http_sub_module             enable ngx_http_sub_module
    --with-http_dav_module             enable ngx_http_dav_module
    --with-http_flv_module             enable ngx_http_flv_module
    --with-http_mp4_module             enable ngx_http_mp4_module
    --with-http_gunzip_module          enable ngx_http_gunzip_module
    --with-http_gzip_static_module     enable ngx_http_gzip_static_module
    --with-http_auth_request_module    enable ngx_http_auth_request_module
    --with-http_random_index_module    enable ngx_http_random_index_module
    --with-http_secure_link_module     enable ngx_http_secure_link_module
    --with-http_degradation_module     enable ngx_http_degradation_module
    --with-http_slice_module           enable ngx_http_slice_module
    --with-http_stub_status_module     enable ngx_http_stub_status_module
    
    --without-http_charset_module      disable ngx_http_charset_module
    --without-http_gzip_module         disable ngx_http_gzip_module
    --without-http_ssi_module          disable ngx_http_ssi_module
    --without-http_userid_module       disable ngx_http_userid_module
    --without-http_access_module       disable ngx_http_access_module
    --without-http_auth_basic_module   disable ngx_http_auth_basic_module
    --without-http_mirror_module       disable ngx_http_mirror_module
    --without-http_autoindex_module    disable ngx_http_autoindex_module
    --without-http_geo_module          disable ngx_http_geo_module
    --without-http_map_module          disable ngx_http_map_module
    --without-http_split_clients_module disable ngx_http_split_clients_module
    --without-http_referer_module      disable ngx_http_referer_module
    --without-http_rewrite_module      disable ngx_http_rewrite_module
    --without-http_proxy_module        disable ngx_http_proxy_module
    --without-http_fastcgi_module      disable ngx_http_fastcgi_module
    --without-http_uwsgi_module        disable ngx_http_uwsgi_module
    --without-http_scgi_module         disable ngx_http_scgi_module
    --without-http_grpc_module         disable ngx_http_grpc_module
    --without-http_memcached_module    disable ngx_http_memcached_module
    --without-http_limit_conn_module   disable ngx_http_limit_conn_module
    --without-http_limit_req_module    disable ngx_http_limit_req_module
    --without-http_empty_gif_module    disable ngx_http_empty_gif_module
    --without-http_browser_module      disable ngx_http_browser_module
    --without-http_upstream_hash_module disable ngx_http_upstream_hash_module
    --without-http_upstream_ip_hash_module disable ngx_http_upstream_ip_hash_module
    --without-http_upstream_least_conn_module disable ngx_http_upstream_least_conn_module
    --without-http_upstream_random_module disable ngx_http_upstream_random_module
    --without-http_upstream_keepalive_module disable ngx_http_upstream_keepalive_module
    --without-http_upstream_zone_module disable ngx_http_upstream_zone_module
    
    --with-http_perl_module            enable ngx_http_perl_module
    --with-http_perl_module=dynamic    enable dynamic ngx_http_perl_module
    --with-perl_modules_path=PATH      set Perl modules path
    --with-perl=PATH                   set perl binary pathname
    
    --http-log-path=PATH               set http access log pathname
    --http-client-body-temp-path=PATH  set path to store http client request body temporary files
    --http-proxy-temp-path=PATH        set path to store http proxy temporary files
    --http-fastcgi-temp-path=PATH      set path to store http fastcgi temporary files
    --http-uwsgi-temp-path=PATH        set path to store http uwsgi temporary files
    --http-scgi-temp-path=PATH         set path to store http scgi temporary files
    
    --without-http                     disable HTTP server
    --without-http-cache               disable HTTP cache
    
    --with-mail                        enable POP3/IMAP4/SMTP proxy module
    --with-mail=dynamic                enable dynamic POP3/IMAP4/SMTP proxy module
    --with-mail_ssl_module             enable ngx_mail_ssl_module
    --without-mail_pop3_module         disable ngx_mail_pop3_module
    --without-mail_imap_module         disable ngx_mail_imap_module
    --without-mail_smtp_module         disable ngx_mail_smtp_module
    
    --with-stream                      enable TCP/UDP proxy module (default on)
    --with-stream=dynamic              enable dynamic TCP/UDP proxy module
    --with-stream_ssl_module           enable ngx_stream_ssl_module (default on)
    --with-stream_realip_module        enable ngx_stream_realip_module
    --with-stream_geoip_module         enable ngx_stream_geoip_module
    --with-stream_geoip_module=dynamic enable dynamic ngx_stream_geoip_module
    --with-stream_ssl_preread_module   enable ngx_stream_ssl_preread_module
    --without-stream_limit_conn_module disable ngx_stream_limit_conn_module
    --without-stream_access_module     disable ngx_stream_access_module
    --without-stream_geo_module        disable ngx_stream_geo_module
    --without-stream_map_module        disable ngx_stream_map_module
    --without-stream_split_clients_module disable ngx_stream_split_clients_module
    --without-stream_return_module     disable ngx_stream_return_module
    --without-stream_upstream_hash_module disable ngx_stream_upstream_hash_module
    --without-stream_upstream_least_conn_module disable ngx_stream_upstream_least_conn_module
    --without-stream_upstream_random_module disable ngx_stream_upstream_random_module
    --without-stream_upstream_zone_module disable ngx_stream_upstream_zone_module
    
    --with-google_perftools_module     enable ngx_google_perftools_module
    --with-cpp_test_module             enable ngx_cpp_test_module
    --add-module=PATH                  enable external module
    --add-dynamic-module=PATH          enable dynamic external module
    
    --with-compat                      dynamic modules compatibility
    --with-cc=PATH                     set C compiler pathname
    --with-cpp=PATH                    set C preprocessor pathname
    --with-cc-opt=OPTIONS              set additional C compiler options
    --with-ld-opt=OPTIONS              set additional linker options
    --with-cpu-opt=CPU                 build for the specified CPU, valid values: pentium, pentiumpro, pentium3, pentium4, athlon, opteron, sparc32, sparc64, ppc64
    
    --without-pcre                     disable PCRE library usage
    --with-pcre                        force PCRE library usage                                     # perl兼容的正规表达式库
    --with-pcre=DIR                    set path to PCRE library sources
    --with-pcre-opt=OPTIONS            set additional build options for PCRE
    --with-pcre-jit                    build PCRE with JIT compilation support
    
    --with-zlib=DIR                    set path to zlib library sources
    --with-zlib-opt=OPTIONS            set additional build options for zlib
    --with-zlib-asm=CPU                use zlib assembler sources optimized for the specified CPU, valid values: pentium, pentiumpro
    
    --with-libatomic                   force libatomic_ops library usage
    --with-libatomic=DIR               set path to libatomic_ops library sources
    
    --with-openssl=DIR                 set path to OpenSSL library sources
    --with-openssl-opt=OPTIONS         set additional build options for OpenSSL
    
    --dry-run                          dry running the configure, for testing only
    --platform=PLATFORM                forcibly specify a platform name, for testing only
    

感谢您的反馈。如果您有关于如何使用 KubeSphere 的具体问题,请在 Slack 上提问。如果您想报告问题或提出改进建议,请在 GitHub 存储库中打开问题。