Nginx簡單配置
#運行Nginx的用戶
user nginx;
#Nginx運行的進程數,擁有幾個邏輯CPU,就設置為幾個worker_processes 為宜,但是 worker_processes 超過8個就沒有多大意義了
worker_processes 8;
#制定進程到cpu(四cpu:0001 0010 0100 1000)
worker_cpu_affinity 0001 0010 0100 1000 0001 0010 0100 1000;
#worker_rlimit_nofile配置要和系統的單進程打開文件數一致。
worker_rlimit_nofile 100000;
#錯誤日志,在出現錯的時候可以tail查看,查找具體的錯誤
error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
#pid文件
pid /var/run/nginx.pid;
events {
#使用epoll(linux2.6的高性能方式)
use epoll;
#每個進程最大連接數(最大連接=連接數x進程數)
worker_connections 10240;
}
http {
#文件擴展名與文件類型映射表
include /etc/nginx/mime.types;
#默認文件類型
default_type application/octet-stream;
#日志文件格式
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
#access log
access_log /var/log/nginx/access.log main;
#tcp and gzip相關配置
charset UTF-8;
#嵌套upstream.conf
include upstream.conf;
#長鏈接超時時間
keepalive_timeout 65;
limit_conn_zone $binary_remote_addr zone=addr:10m;
# Load config files from the /etc/nginx/conf.d directory
include /etc/nginx/conf.d/*.conf;
}
user nginx;
#Nginx運行的進程數,擁有幾個邏輯CPU,就設置為幾個worker_processes 為宜,但是 worker_processes 超過8個就沒有多大意義了
worker_processes 8;
#制定進程到cpu(四cpu:0001 0010 0100 1000)
worker_cpu_affinity 0001 0010 0100 1000 0001 0010 0100 1000;
#worker_rlimit_nofile配置要和系統的單進程打開文件數一致。
worker_rlimit_nofile 100000;
#錯誤日志,在出現錯的時候可以tail查看,查找具體的錯誤
error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
#pid文件
pid /var/run/nginx.pid;
events {
#使用epoll(linux2.6的高性能方式)
use epoll;
#每個進程最大連接數(最大連接=連接數x進程數)
worker_connections 10240;
}
http {
#文件擴展名與文件類型映射表
include /etc/nginx/mime.types;
#默認文件類型
default_type application/octet-stream;
#日志文件格式
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
#access log
access_log /var/log/nginx/access.log main;
#tcp and gzip相關配置
sendfile on;
tcp_nopush on;
tcp_nodelay on;
server_tokens off;
gzip on;
gzip_static on;
gzip_comp_level 5;
gzip_min_length 1024;
#默認編碼charset UTF-8;
#嵌套upstream.conf
include upstream.conf;
#長鏈接超時時間
keepalive_timeout 65;
limit_conn_zone $binary_remote_addr zone=addr:10m;
# Load config files from the /etc/nginx/conf.d directory
include /etc/nginx/conf.d/*.conf;
}