1. 程式人生 > 其它 >中標麒麟v10系統部署nginx

中標麒麟v10系統部署nginx

wget https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz 
wget http://zlib.net/zlib-1.2.11.tar.gz
wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz
wget http://nginx.org/download/nginx-1.18.0.tar.gz
################################################################################################

$ yum install gcc
-c++ gd gd-devel -y #安裝c編譯器,gd依賴 $ useradd -M -s /sbin/nologin nginx #建立nginx使用者用於管理後期nginx服務 $ tar xf nginx-kylin_1.18.0.tar.gz -C /data/ #該包為nginx通用包,包括centos,麒麟x86,麒麟arm架構 $ cd /data/nginx/nginx-1.18.0 #進入nginx編譯目錄,準備一下編譯 $ ./configure --user=nginx --group=nginx --sbin-path=/usr/sbin/ --prefix=/usr/local/nginx/ --with-pcre=/data/nginx/pcre-8.44
/ --with-zlib=/data/nginx/zlib-1.2.11/ --with-openssl=/data/nginx/openssl-1.1.1g/ --with-http_stub_status_module --with-http_ssl_module --with-http_image_filter_module --with-http_degradation_module --with-file-aio --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_degradation_module--with-http_flv_module --with-http_gzip_static_module --with-http_gunzip_module --with-http_image_filter_module --with-http_mp4_module --with-http_realip_module --with-http_random_index_module --with-mail --with-mail_ssl_module --with-stream --with-stream_ssl_module --with-debug --with-pcre-jit --add-module=/data/nginx/headers-more-nginx-module-master --add-module=/data/nginx/nginx-plugin-master $ make
-j2 && make install #以前預編譯完成,開始編譯及安裝

##########vim /usr/local/nginx/conf/nginx.conf    #修改nginx主配置檔案一下內容
user  nginx;
worker_processes  auto;

#pid        logs/nginx.pid;

events {
    worker_connections  102400;
}

http {
    include    /etc/nginx/conf.d/*.conf;
    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"';

    log_format logstash_json '{"@timestamp": "$time_iso8601", '
                        '"time_local": "$time_local", '
                        '"remote_addr": "$remote_addr", '
                        '"remote_user": "$remote_user", '
                        '"request": "$request", '
                        '"referer": "$http_referer", '
                        '"request_time": "$request_time", '
                        '"request_body": "$request_body", '
                        '"uri": $uri, '
                        '"status": $status, '
                        '"logger": "nginx", '
                        '"agent": "$http_user_agent", '
                        '"scheme": "scheme", '
                        '"server_name": $server_name, '
                        '"bytes":$body_bytes_sent, '
                        '"bytes_sent":$bytes_sent, '
                        '"http_cookie": $http_cookie, '
                        '"http_host": $http_host, '
                        '"http_x_api_method": $http_x_api_method, '
                        '"http_x_api_sign": "$http_x_api_sign", '
                        '"http_x_api_userid":$http_x_api_userid, '
                        '"http_x_forwarded": "$http_x_forwarded_for", '
                        '"upstr_addr": "$upstream_addr",'
                        '"upstr_host": "$upstream_http_host",'
                        '"upstream_status": "$upstream_status",'
                        '"ups_resp_time": "$upstream_response_time"}';

    access_log  logs/access.log  logstash_json;
    error_log  logs/error.log;

    #sendfile        on;
    #tcp_nopush     on;
    #keepalive_timeout  0;
    keepalive_timeout  360s;

    gzip on;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";
    gzip_min_length  1k;
    gzip_buffers     4 16k;
    gzip_http_version 1.0;
    gzip_comp_level 6;
    gzip_proxied any;
    gzip_vary on;
    gzip_types *;
    sendfile        on;
    tcp_nopush     on;
    server_names_hash_bucket_size 256;
    client_header_buffer_size 256k;
    large_client_header_buffers 4 256k;
    client_max_body_size 10240m;
    proxy_connect_timeout 3600s;
    proxy_send_timeout 3600s;
    proxy_read_timeout 3600s;
    client_header_timeout 15s;
    client_body_timeout 15s;
    send_timeout 360s;

    gzip_types text/css text/xml text/plain text/mathml text/vnd.sun.j2me.app-descriptor text/vnd.wap.wml text/x-component image/gif image/jpeg image/png image/tiff image/vnd.wap.wbmp image/x-icon image/x-jng image/x-ms-bmp image/svg+xml image/webp application/javascript application/atom+xml application/rss+xml application/font-woff application/java-archive application/json application/mac-binhex40 application/msword application/vnd.ms-powerpoint application/vnd.ms-excel application/pdf;

    server {
        listen       80;
        server_name  localhost;

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

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}
$  mkdir -p /etc/nginx/conf.d      #建立域名存放路徑
$ /usr/local/nginx/sbin/nginx -t   #測試nginx應用服務配置是否報錯
$ /usr/local/nginx/sbin/nginx      #啟動nginx服務
$ netstat -tlnp |grep 80           #查詢nginx監聽埠