Several advanced extended applications of Nginx

Source: Internet
Author: User
Tags epoll file size log

Nginx.conf Configuration explanation

Detailed user www www; Define the Nginx running user and group Worker_processes 8; #[Debug | info | notice | warn | error | crit] Error_log/data1/logs/nginx_error.log crit; Pid/usr/local/webserver/nginx/nginx.pid;    
#Specifies the value for maximum file descriptors the can is opened by this process.    
Worker_rlimit_nofile 65535;    
The maximum number of file descriptors that a nginx process opens, the theoretical value should be divided by the number of open files (ulimit-n) Nginx processes, and the Nginx allocation request is not so homogeneous, so it is best to be consistent with the Ulimit-n value.    
# Use [kqueue | rtsig | epoll |/dev/poll | poll]; Events use Epoll; Reference event model Worker_connections 65535; Maximum number of connections per process (maximum connection = number of connections x processes) #设定 HTTP server http include mime.types; File name extension and file type mapping table Default_type Application/octet-stream; #默认文件类型 #charset gb2312; Default encoding server_names_hash_bucket_size 128; #服务器名字的 hash Table size Client_header_buffer_size 32k; Upload file size limit large_client_header_buffers 4 32k; Set request slow client_max_body_size 8m; Set request slow sendfile on; #开启高效文件传输模式 Tcp_nopush on; Prevent network blocking tcp_nodelay on; Preventing Network Congestion KeePalive_timeout 60; The timeout #FastCGI is to improve the performance of the site-reduce resource consumption and improve access speed. For more information on FastCGI see: http://www.fastcgi.com fastcgi_connect_timeout 30    
0;    
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; Gzip_min_length 1k; #最小压缩文件大小 gzip_buffers 4 16k;    
#压缩缓冲区 Gzip_http_version 1.0; #压缩版本 (default 1.1, front end for squid2.5 using 1.0 gzip_comp_level 2; compression level gzip_types Text/plain application/x-javascript text/c    
SS Application/xml;    
Compression type, the default is already included text/html so there is no need to write, of course, there will be no problem, but there will be a warn gzip_vary on; #limit_zone crawler $binary _remote_addr 10m;    
Server Listen 80;    
server_name www.opendoc.com.cn index index.html index.htm index.php;    
Root/data0/htdocs/opendoc; Location ~. *\.    
(PHP|PHP5) $ #fastcgi_pass unix:/tmp/php-cgi.sock;    
Fastcgi_pass 127.0.0.1:9000;    
Fastcgi_index index.php; Includefcgi.conf; #对图片缓存 Location ~ *\. (gif|jpg|jpeg|png|bmp|swf) $ expires 30d; #对 JS CSS Cache location ~. *\. (JS|CSS) $ expires 1h; #日志设定 log_format access ' $remote _addr-$remote _user [$time _local] "$request" "$status $body _bytes_sent" $http _refer    
Er "" $http _user_agent "$http _x_forwarded_for";    
#日志的格式 Access_log/data1/logs/access.log access; }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.