zoukankan      html  css  js  c++  java
  • 编译安装基于nginx与lua的高性能web平台openresty

    1、首先编译安装nginx(不多说)

    2、开始安装openresty

    cd /usr/local/src

    wget https://openresty.org/download/openresty-1.11.2.2.tar.gz

    tar xf openresty-1.11.2.2.tar.gz

    cd openresty-1.11.2.2/

    编译开始

    --prefix=/usr/local/nginx --sbin-path=/usr/sbin/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/log/nginx.pid --error-log-path=/usr/local/nginx/log/error.log --http-log-path=/usr/local/nginx/log/access.log --lock-path=/var/lock/nginx.lock --with-luajit --with-http_gunzip_module --with-pcre --with-pcre-jit --with-http_perl_module --with-ld-opt="-Wl,-E" --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-select_module --with-poll_module --with-file-aio --with-http_degradation_module --with-libatomic --http-client-body-temp-path=/var/tmp/nginx/client_body --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi

    编译过程中会出现各种确实库和模块的错误,根据提示自行补充缺少的依赖库和模块。

    安装

    gmake && gmake install

    查看是否安装成功:

    nginx -v

    创建目录

    mkdir -p /var/tmp/nginx

    配置

    user                                    nginx;
    pid                                     /var/run/nginx.pid;
     
    worker_processes                        2;
    worker_rlimit_nofile                    65534;
     
    events {
        use                                 epoll;
        worker_connections                  65534;
        multi_accept                        on;
    }
     
    http {
        client_body_buffer_size             16k;
        client_body_timeout                 30s;
        client_header_buffer_size           2k;
        large_client_header_buffers         4 16k;
        client_header_timeout               30s;
        client_max_body_size                8m;
        keepalive_timeout                   300;
        output_buffers                      2 16k;
        send_timeout                        60s;
        server_names_hash_bucket_size       128;
        reset_timedout_connection           on;
     
    #gzip
        gzip on;
        gzip_min_length                     512;
        gzip_buffers                        16 4k;
        gzip_comp_level                     4;
        gzip_proxied                        any;
     
    #cache
        open_file_cache                     max=204800 inactive=60s;
        open_file_cache_errors              on;
        open_file_cache_min_uses            1;
        open_file_cache_valid               60s;
     
    #proxy
        proxy_buffer_size                   32k;
        proxy_buffers                       8 32k;
        proxy_busy_buffers_size             32k;
        proxy_cache_path                    /var/tmp/nginx/proxy_cache levels=1:2 keys_zone=content:200m inactive=30d max_size=10g;
        proxy_cache_path                    /var/tmp/nginx/proxy_cache/enginx levels=1:2 keys_zone=enginx:200m inactive=30d max_size=10g;
        proxy_cache_key                     $host$proxy_host$uri$is_args$args;
        proxy_connect_timeout               60s;
        proxy_read_timeout                  300s;
        proxy_send_timeout                  300s;
        proxy_temp_file_write_size          32k;
        proxy_temp_path                     /var/tmp/nginx/proxy_temp;
        proxy_set_header                    Host $host;
        proxy_set_header                    X-Real-IP $remote_addr;
        proxy_set_header                    X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header                    X-Scheme $scheme;
        proxy_set_header                    Accept-Encoding '';
        real_ip_header                      X-Forwarded-For;
     
    #log
        log_format main                    '$remote_addr - $remote_user [$time_local] "$request" $http_host ' 
                                            '$status $body_bytes_sent "$http_referer" '
                                            '"$http_user_agent" "$http_x_forwarded_for" '
                                            '$upstream_addr $upstream_status $upstream_cache_status "$upstream_http_content_type" $upstream_response_time > $request_time';
     
        open_log_file_cache                 max=204800 inactive=20s valid=1m min_uses=1;
        error_log                           /var/log/nginx/error.log error;
     
    #host configure file
        include                             /usr/local/nginx/conf.d/*.ngx.conf;
     
    #main configure
        server_tokens                       off;
        sendfile                            off;
        tcp_nopush                          on;
        tcp_nodelay                         off;
        charset                             utf-8;
        include                             /usr/local/nginx/mime.types;
        default_type                        text/html;
    }

    创建目录

    mkdir /usr/local/nginx/conf.d

    新建文件

    local.ngx.conf

    server {
     
        listen                  80;
     
        server_name             www.web-t1.t.com;
     
        return 301 http://web-t1.t.com$request_uri;
     
    }
     
    server {
     
        listen                  80;
     
        server_name             web-t1.t.com;
     
        root                    /usr/local/html/web-t1.t.com/public_html/;
     
        access_log              /usr/local/html/web-t1.t.com/logs/ngx_access.log main;
     
        location / {
     
            index               index.html;
     
        }
     
    }

    启动测试停止nginx: nginx  、nginx -t 、nginx -s stop

  • 相关阅读:
    网上找的一个读取wave文件的代码片段
    用c++简单实现智能指针(转)
    剖析ifstream打开含中文路径名文件失败的原因(转)
    我是一个程序员
    .NET简谈委“.NET技术”托链 狼人:
    Entity Framework “.NET技术”4.1 推荐英文教程 狼人:
    Azure和Bing Maps API示“.NET技术”例经验分享 狼人:
    .NET中的异步编程“.NET技术”:使用F#简化异步编程 狼人:
    C#类类型“.NET技术” 狼人:
    Silverlight 应“.NET技术”用整合 狼人:
  • 原文地址:https://www.cnblogs.com/xiongyoutom/p/8777236.html
Copyright © 2011-2022 走看看