Linux 에 Lnmp 환경 을 설치 한 Nginx 프로필 상세 설명
22449 단어 Linux 상용 소프트웨어 설치 및 설정PHP 기술
######Nginx nginx.conf #####
# Nginx
user www www;
#nginx , CPU 。
worker_processes 8;
# ,[ debug | info | notice | warn | error | crit ]
error_log /usr/local/nginx/logs/error.log info;
# pid
pid /usr/local/nginx/logs/nginx.pid;
# :
#
# nginx , (ulimit -n) nginx , nginx , ulimit -n 。
# linux 2.6 65535,worker_rlimit_nofile 65535。
# nginx , 10240, 3-4 10240 , 502 。
worker_rlimit_nofile 65535;
events
{
# ,use [ kqueue | rtsig | epoll | /dev/poll | select | poll ]; epoll
# Linux 2.6 I/O ,linux epoll, FreeBSD , kqueue 。
# :
# apache ,nginx ,
#A)
#Select、poll , ,nginx select poll
#B)
#Kqueue: FreeBSD 4.1+, OpenBSD 2.9+, NetBSD 2.0 MacOS X. MacOS X kqueue 。
#Epoll: Linux 2.6 。
#/dev/poll: Solaris 7 11/99+,HP/UX 11.22+ (eventport),IRIX 6.5.15+ Tru64 UNIX 5.1A+。
#Eventport: Solaris 10。 , 。
use epoll;
# ( = * )
# , , , cpu 100% 。 , nginx 。
worker_connections 65535;
#keepalive 。
keepalive_timeout 60;
# 。 , 1k, 1k, 。
# getconf PAGESIZE 。
#[root@web001 ~]# getconf PAGESIZE
#4096
# client_header_buffer_size 4k , client_header_buffer_size “ ” 。
client_header_buffer_size 4k;
# , ,max , ,inactive 。
open_file_cache max=65535 inactive=60s;
# 。
# :open_file_cache_valid time :open_file_cache_valid 60 :http, server, location open_file_cache .
open_file_cache_valid 80s;
#open_file_cache inactive , , , , inactive , 。
# :open_file_cache_min_uses number :open_file_cache_min_uses 1 :http, server, location open_file_cache , , cache .
open_file_cache_min_uses 1;
# :open_file_cache_errors on | off :open_file_cache_errors off :http, server, location cache .
open_file_cache_errors on;
}
# http ,
http
{
#
include mime.types;
#
default_type application/octet-stream;
#
#charset utf-8;
# hash
# hash server_names_hash_max_size server_names_hash_bucket_size 。 hash bucket size hash , 。
# , hash 。
# hash bucket size , , 2。 , 。
# , Nginx hash max size hash bucket size , .
server_names_hash_bucket_size 128;
# 。 , 1k, 1k, 。 getconf PAGESIZE 。
client_header_buffer_size 32k;
# 。nginx client_header_buffer_size buffer header , header , large_client_header_buffers 。
large_client_header_buffers 4 64k;
# nginx
client_max_body_size 8m;
# ,sendfile nginx sendfile , on, IO , off, I/O , 。 : off。
#sendfile nginx sendfile (zero copy ) , , on。 IO , off, IO , uptime。
sendfile on;
# , , 。
autoindex on;
# socke TCP_CORK , sendfile
tcp_nopush on;
tcp_nodelay on;
# ,
keepalive_timeout 120;
#FastCGI : , 。 。
fastcgi_connect_timeout 300;
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
gzip on; # gzip
gzip_min_length 1k; #
gzip_buffers 4 16k; #
gzip_http_version 1.0; # ( 1.1, squid2.5 1.0)
gzip_comp_level 2; #
gzip_types text/plain application/x-javascript text/css application/xml; # , textml, , , warn。
gzip_vary on;
# IP
#limit_zone crawler $binary_remote_addr 10m;
#
upstream piao.jd.com {
#upstream ,weight , 。weigth , 。
server 192.168.80.121:80 weight=3;
server 192.168.80.122:80 weight=2;
server 192.168.80.123:80 weight=3;
#nginx upstream 4
#1、 ( )
# , down , 。
#2、weight
# ,weight , 。
# :
#upstream bakend {
# server 192.168.0.14 weight=10;
# server 192.168.0.15 weight=10;
#}
#2、ip_hash
# ip hash , , session 。
# :
#upstream bakend {
# ip_hash;
# server 192.168.0.14:88;
# server 192.168.0.15:80;
#}
#3、fair( )
# , 。
#upstream backend {
# server server1;
# server server2;
# fair;
#}
#4、url_hash( )
# url hash , url , 。
# : upstream hash ,server weight ,hash_method hash
#upstream backend {
# server squid1:3128;
# server squid2:3128;
# hash $request_uri;
# hash_method crc32;
#}
#tips:
#upstream bakend{# Ip }{
# ip_hash;
# server 127.0.0.1:9090 down;
# server 127.0.0.1:8080 weight=2;
# server 127.0.0.1:6060;
# server 127.0.0.1:7070 backup;
#}
# server proxy_pass http://bakend/;
# :
#1.down server
#2.weight weight , 。
#3.max_fails: 1. , proxy_next_upstream
#4.fail_timeout:max_fails , 。
#5.backup: backup down , backup 。 。
#nginx , server 。
#client_body_in_file_only On client post debug
#client_body_temp_path 3
#location URL .
}
#
server
{
#
listen 80;
# ,
server_name www.jd.com jd.com;
index index.html index.htm index.php;
root /data/www/jd;
# ******
location ~ .*.(php|php5)?$
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
#
location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 10d;
}
#JS CSS
location ~ .*.(js|css)?$
{
expires 1h;
}
#
#$remote_addr $http_x_forwarded_for ip ;
#$remote_user: ;
#$time_local: ;
#$request: url http ;
#$status: ; 200,
#$body_bytes_sent : ;
#$http_referer: ;
#$http_user_agent: ;
# web , IP , $remote_add IP iP 。 http , x_forwarded_for , IP 。
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/nginx/logs/host.access.log main;
access_log /usr/local/nginx/logs/host.access.404.log log404;
# "/"
location / {
proxy_pass http://127.0.0.1:88;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
# Web X-Forwarded-For IP
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# , 。
proxy_set_header Host $host;
#
client_max_body_size 10m;
# ,
# , 256k, , firefox IE , 256k , 。 , client_body_buffer_size , ,8k 16k, 。
# firefox4.0 IE8.0, ,200k , 500 Internal Server Error
client_body_buffer_size 128k;
# nginx HTTP 400 。
proxy_intercept_errors on;
# _
#nginx ( )
proxy_connect_timeout 90;
# ( )
# _
proxy_send_timeout 90;
# , ( )
# _ _ ( )
proxy_read_timeout 90;
# (nginx)
# , , proxy_buffers ,
proxy_buffer_size 4k;
#proxy_buffers , 32k
# ( ) , , 4k 8k
proxy_buffers 4 32k;
# (proxy_buffers*2)
proxy_busy_buffers_size 64k;
# proxy_temp_path ,
# , , upstream
proxy_temp_file_write_size 64k;
}
# Nginx
location /NginxStatus {
stub_status on;
access_log on;
auth_basic "NginxStatus";
auth_basic_user_file confpasswd;
#htpasswd apache htpasswd 。
}
#
# jsp tomcat resin
location ~ .(jsp|jspx|do)?$ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080;
}
# nginx tomcat resin
location ~ .*.(htm|html|gif|jpg|jpeg|png|bmp|swf|ioc|rar|zip|txt|flv|mid|doc|ppt|
pdf|xls|mp3|wma)$
{
expires 15d;
}
location ~ .*.(js|css)?$
{
expires 1h;
}
}
}
######Nginx nginx.conf #####
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
fastdfs 설치 및 설정# cd /usr/local/src/nginx # tar zxvf pcre-8.12.tar.gz # cd pcre-8.12 # ./configure \ # make & make install 4.2 압축 풀기 fa...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.