nginx FastCGI 최적화

3327 단어
FastCGI 최적화
fastcgi 관련 매개 변수 목록 설명
주 프로필 nginx. conf 에 설정
[root@web01 conf]# cat /application/nginx/conf/nginx.conf
worker_processes  2;
worker_cpu_affinity 0101 1010;
error_log logs/error.log;
 
#  Nginx worker         
worker_rlimit_nofile 65535;
 
user www www;
events {
    #               
    worker_connections  20480;
    #  epoll  
    use epoll;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    #sendfile        on;
    #keepalive_timeout  65;
    #      
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
 
 
    #    
    include /application/nginx/conf/extra/www.conf;
    include /application/nginx/conf/extra/blog.conf;
    include /application/nginx/conf/extra/bbs.conf;
    include /application/nginx/conf/extra/edu.conf;
    include /application/nginx/conf/extra/phpmyadmin.conf;
    include /application/nginx/conf/extra/status.conf;
 
    #nginx  ----------------------
    #     
    server_tokens on;
 
    #              
    server_names_hash_bucket_size 64;
    server_names_hash_max_size 2048;
 
    #          
    sendfile on;
    #         
    #tcp_nopush on;
    #  I/O  
    tcp_nodelay on;
 
    #                65 
    keepalive_timeout 60;
    
    #                      60 
    client_header_timeout 15;
    
    #                     60 
    client_body_timeout 15;
    
    #                 60 
    send_timeout 25;
 
    #             1m
    client_max_body_size 8m;
 
    #nginx php  FastCGI       
    #      
    fastcgi_connect_timeout 240;
    fastcgi_send_timeout 240;
    fastcgi_read_timeout 240;
    #  /    
    fastcgi_buffer_size 64k;
    fastcgi_buffers 4 64k;
    fastcgi_busy_buffers_size 128k;
    fastcgi_temp_file_write_size 128k;
    fastcgi_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;
}

가상 호스트 설정 파일 에 설정
[root@web01 conf]# cat /application/nginx/conf/extra/www.conf 
server {
    listen  80;
    server_name www.abc.com;
    rewrite ^(.*)$  https://$host$1 permanent;
}
server {
    listen       443;
    server_name  www.abc.com;
 
    #https  
    ssl on;
    ssl_certificate /application/nginx/conf/key/server.crt;
    ssl_certificate_key /application/nginx/conf/key/server.key;
 
    #    
    access_log  logs/access_www.log  main buffer=32k flush=5s;
    location / {
        root   html/www;
        index  index.php index.html index.htm;
    }
    #     
    #server_tokens on;
 
    #php  
    location ~ .*\.(php|php5)?$ {
        root html/www;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi.conf;
 
        #FastCGI       
        #fastcgi_cache ngx_fcgi_cache;
        fastcgi_cache_valid 200 302 1h;
        fastcgi_cache_valid 301 1d;
        fastcgi_cache_valid any 1m;
        fastcgi_cache_min_uses 1;
        fastcgi_cache_use_stale error timeout invalid_header http_500;
        fastcgi_cache_key http://$host$request_uri;
    }
}

다음으로 전송:https://blog.51cto.com/13673885/2299774

좋은 웹페이지 즐겨찾기