nginx.conf basic configuration instructions

# User running 
the User the nobody; 
# start the process, and usually set to equal the number of cpu 
worker_processes   1 ; 
 
# global error log and PID files 
#error_log logs / error.log;  #error_log logs / error.log Notice;  #error_log logs / error .log info ; # PID logs / nginx.pid; # operation mode and limit the number of connections is multiplexed events {#epoll IO (I / a manner that O multiplexing) is, only for # linux2.6 more kernel , can greatly improve the performance of nginx use epoll; # single background process worker process maximum number of concurrent links worker_connections 1024 ; # is the total number of concurrent worker_processes and worker_connections product worker_processes * = # that max_clients worker_connections # in the case of reverse proxy set up under , max_clients worker_processes * worker_connections = / . 4Why # reverse proxy to why the above is divided by 4, it should be said is an empirical value # Based on the above conditions, the maximum number of connections Nginx Server under normal circumstances may be payable as follows: 4 * 8000 = 32000 set with the value of physical memory # worker_connections the maximum number of concurrent file size by about # IO constrained because, max_clients value must be less than the system can be opened # and the number of files maximum number of files and memory proportional to the size of the system can open, general 1GB memory machines can be opened about 10 we take a look around Wan # 360M memory, the number of file handles that can be opened is the number of VPS: # $ CAT / proc / SYS / FS / File- max output # 34336 # 32000 < 34336 , the total number of concurrent connections that is less than the system can open total number of file handles, so that within the operating system can withstand a range of # Therefore, the value of worker_connections needs to be appropriately set # such that the total number of concurrent less than the operating system may open the total number of the maximum file worker_processes process number and the system can open the maximum # number of files and its essence is based on the physical CPU and the host # Configure Of course, the theoretical and the actual total number of concurrent may be biased, because there are a host of other worker process consumes system resources. The ulimit -SHn # 65535 } {# HTTP set mime type, file type defined by the mime.type include mime.types; default_type application / octet-stream; # log format set main log_format ' $ REMOTE_ADDR - $ REMOTE_USER [$ time_local] "$ Request" ' ' $ $ body_bytes_sent Status "$ HTTP_REFERER" ' ' "$ HTTP_USER_AGENT" "$ HTTP_X_FORWARDED_FOR" ' ; access_log logs / Access. log main; #sendfile directive specifies whether nginx sendfile call function (zero copy mode) to output file # for general application, must be set to on, # if used to download applications such as disk IO heavy load applications, can be set to off, # disk to balance the network the I / O processing speed and reduce the system uptime sendfile on;. #tcp_nopush on; # connection time #keepalive_timeout 0 ; keepalive_timeout 65 ; TCP_NODELAY ON; # open gzip compression gzip ON; gzip_disable " MSIE [. 1 -6]. " ;# Setting request buffer client_header_buffer_size 128k; large_client_header_buffers4 128K; # set the virtual host configuration server {# listening on port 80 the listen 80 ; # definitions used www.nginx.cn access server_name www.nginx.cn; the default web root directory location # define the server's root html; # set this virtual hosts access log logs access_log / nginx.access.log main; # default request LOCATION / {name #define Home index file index index.php index.html index.htm;} # define error page error_page 500 502 503 504 / 50x.html; LOCATION = / 50x.html # {} static files, their processing Nginx ^ ~ LOCATION / (Images | JavaScript | JS | CSS | Flash | Media | static) / {# expire 30 days, no static files how to update, you can set expiration bigger, # if frequent updates, you can set smaller. expires 30d;} #PHP FastCGI script processing request is forwarded to all of the default configuration using FastCGI ~ LOCATION.. .php $ {fastcgi_pass 127.0. 0.1: 9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } #禁止访问 .htxxx 文件 location ~ /.ht { deny all; } } }

Guess you like

Origin www.cnblogs.com/zyxy5207/p/11391509.html