Nginx编译安装

以下是安装中缺少会报错的包

yum install -y gcc gcc-c++
yum -y install openssl openssl-devel
yum install gd-devel -y
yum install perl perl-devel perl-ExtUtils-Embed -y

安装pcre,下载安装包安装即可
Nginx编译参数

./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_realip_module --with-http_perl_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-file-aio --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_gunzip_module --with-http_image_filter_module --with-ld-opt="-Wl,-E"  --with-pcre=/usr/local/pcre-8.37

nginx配置参考

user  root;
worker_processes  8;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

pid        logs/nginx.pid;
worker_rlimit_nofile 102400;

events {
worker_connections 10240;
use epoll;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    log_format  main  '{"logtime": "$time_local", '
                         '"client_ip": "$remote_addr", '
                         '"remote_user": "$remote_user", '
                         '"http_referer": "$http_referer", '
                         '"resp_len": "$body_bytes_sent", '
                         '"waster_time": "$request_time", '
                         '"status": "$status", '
                         '"request_path": "$request", '
                         '"request_method": "$request_method", '
                         '"request_url": "$http_referer", '
                         '"body_bytes_sent":"$body_bytes_sent", '
                         '"http_forwarded": "$http_x_forwarded_for", '
                         '"user_agent": "$http_user_agent" ,'
                         '"upstream":  "$upstream_addr",'
                         '"upstream_status": "$upstream_status"}';

    log_format logstash_json '{"logtime": "$time_local", '
                         '"client_ip": "$remote_addr", '
                         '"remote_user": "$remote_user", '
                         '"http_referer": "$http_referer", '
                         '"resp_len": "$body_bytes_sent", '
                         '"waster_time": "$request_time", '
                         '"status": "$status", '
                         '"request_path": "$request", '
                         '"request_method": "$request_method", '
                         '"request_url": "$http_referer", '
                         '"body_bytes_sent":"$body_bytes_sent", '
                         '"http_forwarded": "$http_x_forwarded_for", '    
                         '"user_agent": "$http_user_agent" ,'
                         '"upstream":  "$upstream_addr",'
                         '"upstream_status": "$upstream_status"}';


   log_format access '{"logtime": "$time_local", '
                         '"client_ip": "$remote_addr", '
                         '"remote_user": "$remote_user", '
                         '"http_referer": "$http_referer", '
                         '"resp_len": "$body_bytes_sent", '
                         '"waster_time": "$request_time", '
                         '"status": "$status", '
                         '"request_path": "$request", '
                         '"request_method": "$request_method", '
                         '"request_url": "$http_referer", '
                         '"body_bytes_sent":"$body_bytes_sent", '
                         '"http_forwarded": "$http_x_forwarded_for", '
                         '"user_agent": "$http_user_agent" ,'
                         '"upstream":  "$upstream_addr",'
                         '"upstream_status": "$upstream_status"}';

    access_log  /app/logs/access.log  logstash_json;


    #sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    #keepalive_timeout  65;

    #gzip  on;
    large_client_header_buffers 4 800k;
    client_header_buffer_size 800k;
    client_max_body_size 2048m;
    client_body_buffer_size 256k;

    server_tokens off;
    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    #keepalive_timeout  200;
    keepalive_timeout 600;
    client_body_timeout 120s;
    client_header_timeout 3m;
    reset_timedout_connection on;
    send_timeout 60;

    fastcgi_connect_timeout 300s;
    fastcgi_read_timeout 300s;
    fastcgi_send_timeout 300s;
    fastcgi_buffers 16 256k;
    fastcgi_buffer_size 256k;
    fastcgi_busy_buffers_size 512k;
    fastcgi_temp_file_write_size 512k;
    fastcgi_intercept_errors on;
    gzip  on;
    #fastcgi_intercept_errors on;

    tcp_nodelay on;
    gzip_min_length  1k;
    gzip_buffers     4 300k;
    gzip_comp_level  4;
    gzip_types      text/plain  text/css text/xml text/vnd.wap.wml text/x-component application/x-javascript image/gif image/jpeg application/atom+xml application/rss+xml application/octet-stream application/x-rar-compressed;
    gzip_vary on;


    include /usr/local/nginx/conf.d/*.conf;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

你可能感兴趣的:(Nginx编译安装)