First, fastcgi param details:
Fastcgi_param Script_filename$document _root$fastcgi_script_name;# Path of the script file request Fastcgi_param query_string$query _string;# the requested parameter; app=123 .Fastcgi_param Request_method$request _method;#requested action (Get,post) Fastcgi_param Content_Type$content _type;# the Content-type field in the request header Fastcgi_param content_length$content _length;#请求头中的Content the-length field. Fastcgi_param Script_name$fastcgi _script_name;# script name Fastcgi_param Request_uri$request _uri; # requested address with no parameters Fastcgi_param Document_uri$document _uri;# Same as $uri. Fastcgi_param Document_root$document _root;#the root directory of the Web site. The value specified in the root directive in the server configuration Fastcgi_param Server_protocol$server _protocol;# the protocol used by the request, usually http/1.0 or http/1.1. Fastcgi_param gateway_interface CGI/1.1;# CGI version Fastcgi_param Server_software nginx/$nginx _version;#nginx version number, can be modified, hiddenFastcgi_param remote_addr$remote _addr;#客户端IPFastcgi_param Remote_port$remote _port;#客户端端口Fastcgi_param server_addr$server _addr;#服务器IP地址Fastcgi_param Server_port$server _port;#服务器端口Fastcgi_param server_name$server _name;#服务器名, the domain name is specified in the server configuration in the server_name # fastcgi_param path_info $path _info; #可自定义变量 # PHP only, required if PHP is built with--enable-force-cgi-redirect # fastcgi_param redirect_status;
Second, the Nginx configuration file
First on a copy of my nginx.conf!
user root root;worker_processes auto;Error_log/usr/local/nginx/logs/nginx_error.LogCrit;pid/usr/local/nginx/logs/nginx.Pid;worker_rlimit_nofile51200; events{ UseEpoll; Worker_connections6000;} http{includeMime.types; Default_type Application/octet-stream; Server_names_hash_bucket_size3526; Server_names_hash_max_size4096; Log_format Combined_realip' $remote _addr $http _x_forwarded_for [$time _local] "$host" $request _uri "$status" ' "$http _referer" "$http _user_agent" '; Sendfile on; Tcp_nopush on; Keepalive_timeout30; Client_header_timeout 3m; Client_body_timeout 3m; Send_timeout 3m; Connection_pool_size256; Client_header_buffer_size 1k; Large_client_header_buffers84k; Request_pool_size 4k; Output_buffers432k; Postpone_output1460; Client_max_body_size 10m; Client_body_buffer_size 256k; Client_body_temp_path/usr/local/nginx/client_body_temp; Proxy_temp_path/usr/local/nginx/proxy_temp; Fastcgi_temp_path/usr/local/nginx/fastcgi_temp; Fastcgi_intercept_errors on; Tcp_nodelay on; gzip on; Gzip_min_length 1k; Gzip_buffers48k; Gzip_comp_level5; Gzip_http_version1.1; Gzip_types text/plain application/x-javascript text/css text/htm application/XML; server {Listen80; server_name localhost; Index index. HTML index.htm Index.PHP; Root/usr/local/nginx/html; Location~ \.php$ {include Fastcgi_params; Fastcgi_pass Unix:/tmp/php-fcgi.sock; Fastcgi_index Index.PHP; Fastcgi_param script_filename $document _root$fastcgi_script_name; } } includeVhost/*. conf;}
2.1> Configuration instructions (part of it):
User root root;#Default User when Nginx starts (that is, what is the identity of the boot Nginx)Worker_processes Auto;#The startup process is usually set to equal the number of CPUs. Equivalent to the number of CPUs (can also be set to auto, let the system to detect)Error_log/usr/local/nginx/logs/nginx_error.LogCrit;#error LogPID/usr/local/nginx/logs/nginx.pid;#main process PID save fileWorker_rlimit_nofile 51200;#number of file descriptors#operating mode and maximum number of connectionsevents{ UseEpoll;#Epoll is a way of multiplexing Io (I/O multiplexing), but only for linux2.6 above the core, can greatly improve the performance of NginxWorker_connections 6000;#Maximum number of concurrent links for a single background worker process session #multi_accept on; #暂时不详}#set up an HTTP server to provide load balancing support with its reverse proxy functionhttp{includeMime.types;#set MIME type, type defined by Mime.type fileDefault_type application/octet-stream; Server_names_hash_bucket_size3526;#Save the hash table size of the server nameServer_names_hash_max_size 4096; #Defining log FormatsLog_format combined_realip ' $remote _addr $http _x_forwarded_for [$time _local] ' $host ' $reque St_uri "$status" "$http _referer" "$http _user_agent"; Sendfile on;#The sendfile directive specifies whether Nginx calls the Sendfile function (zero copy mode) to output the file, which must be set to on for normal applications. If you are using a disk IO heavy load application for download and other applications, you can set it off to balance disk and network I/O processing speed and reduce system uptimeTcp_nopush on;#This is the default, the result is that the packet will not be sent out immediately, wait until the maximum packet, the one-time transmission out, this helps to solve the network congestion. (only valid when sendfile on)Keepalive_timeout30;#connection time-out periodclient_header_timeout 3m; Client_body_timeout 3m; Send_timeout 3m; Connection_pool_size256; Client_header_buffer_size 1k; Large_client_header_buffers84k; Request_pool_size 4k; Output_buffers432k; Postpone_output1460; Client_max_body_size 10m; Client_body_buffer_size 256k; Client_body_temp_path/usr/local/nginx/client_body_temp; Proxy_temp_path/usr/local/nginx/proxy_temp; Fastcgi_temp_path/usr/local/nginx/fastcgi_temp; Fastcgi_intercept_errors on; Tcp_nodelay on;#disables the Nagle algorithm, that is, the data is not cached. #Turn on gzip network compressiongzip on; Gzip_min_length 1k; Gzip_buffers48k; Gzip_comp_level5; Gzip_http_version1.1; Gzip_types text/plain application/x-javascript text/css text/htm application/XML; Gzip_vary on; Gzip_proxied Expired No-cache No-storePrivateAuth; Gzip_disable"MSIE [1-6]\."]; server {Listen80;#Portserver_name localhost;#Server name (domain name, IP)Index index.html index.htm index.php;#Web page index fileroot/usr/local/nginx/html;#Web page Path #PHP script requests are all forwarded to fastcgi processing. Use the fastcgi default configuration.Location ~ \.php$ {includeFastcgi_params; Fastcgi_pass Unix:/tmp/php-fcgi.sock;#specifies that the FASTCGI server listens on ports and addresses. Use UNIX sockets here #Nginx connects FastCGI (PHP) in unix-domain-socket mode. Faster, for high-traffic access #another way to connect the Nginx fastcgi is the HTTP mode of the [127.0.0.1:9000 Way Connection fastcgi (PHP)Fastcgi_index Index. php;#Default Web page fileFastcgi_param Script_filename$document _root$fastcgi_script_name;#Script Access Path } } includeVhost/*. conf; #引入不同虚拟主机的配置}
Cond........................
Nginx: Configuration Detailed description