nginx basic configuration description

  • 2020-05-06 12:17:06
  • OfStack


    user  nfsnobody nfsnobody;  # Users and groups used   
    worker_processes 8;  # Specifies the number of work derived processes   
    error_log /usr/local/web/nginx.0.8.15/nginx_error.log  crit; # Log file addresses   
    pid  /usr/local/web/nginx.0.8.15/nginx.pid; # for PID Stored road strength   
    worker_rlimit_nofile 65535;  # Maximum file descriptor   
    events  
    {  
      use epoll; # Use the event model, general Linux2.6+ use epoll model   
      worker_connections 65535; # Maximum number of links   
    }  
    http  
    {  
      include      mime.types;     
      default_type application/octet-stream;  
      server_names_hash_bucket_size 128; #hash_table  
      client_header_buffer_size 32k; # Request the buffer size of the header   
      large_client_header_buffers 4 32k; # Maximum request header buffer size   
      client_max_body_size 8m; # Client maximum request  8M  
      sendfile on; # Transfer files   
      tcp_nopush    on;  
      keepalive_timeout 60; #60 Second timeout   
      tcp_nodelay on;  
      fastcgi_connect_timeout 300;# The following fastcgi The module configuration   
      fastcgi_send_timeout 300;  
      fastcgi_read_timeout 300;  
      fastcgi_buffer_size 64k;  
      fastcgi_buffers 4 64k;  
      fastcgi_busy_buffers_size 128k;  
      fastcgi_temp_file_write_size 128k;  
      gzip on; # The following gzip The module configuration   
      gzip_min_length  1k;  
      gzip_buffers     4 16k;  
      gzip_http_version 1.0;  
      gzip_comp_level 2;  
      gzip_types       text/plain application/x-javascript text/css application/xml;  
      gzip_vary on;  
      server  
      {  
        listen      80;  # Listening port   
        server_name www.test2.com; #host The name of the   
        index index.html index.htm index.php; # Default access to the home page   
    root  /usr/local/web/www/; # File directory   
    error_page 404 403  http://admin.test.com/404.htm; # The default 404 page   
        location ~ .*\.(php|php5)?$   #php cgi The module   
        {  
          #fastcgi_pass  unix:/tmp/php-cgi.sock;  
          fastcgi_pass  127.0.0.1:9000;  
          fastcgi_index index.php;  
          include fcgi.conf;  
        }  
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$  
    {  
          expires      30d;  
        }  
       location /       #URL Rewrite module   
        {  
          index index.php;  
          if (!-f $request_filename){  
                  rewrite (.*) /admin.php;  
              }  
          try_files $uri $uri/ /index.html;  
        }  
        location ~ .*\.(js|css)?$  
        {  
          expires      1h;  
        }  
        # The following is a log The module - record nginx The log   
        log_format access  '$remote_addr - $remote_user [$time_local] "$request" '  
                  '$status $body_bytes_sent "$http_referer" '  
                  '"$http_user_agent" $http_x_forwarded_for';  
        access_log /usr/local/web/nginx.0.8.15/logs/access.log  access;  
          }  
    } 

Related articles: