linux nginx配置文件详解

配置文件/etc/nginx/nginx.conf

#全局参数设置
worker_processes 4; #设置nginx启动进程的数量,一般设置成与逻辑cpu数量相同
error_log logs/error.log; #指定错误日志
worker_rlimit_nofile 102400; #设置一个nginx进程能打开的最大文件数 不一定生效
pid /var/run/nginx.pid;
events {
worker_connections 1024; #设置一个进程的最大并发连接数
} #模块
#http 服务相关设置
http {
include 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 /var/log/nginx/access.log main; #设置访问日志的位置和格式
sendfile on; #是否调用sendfile函数输出文件,一般设置为on,若nginx是用来进行磁盘IO负载应用时,可以设置为off,降低系统负载
gzip on; #是否开启gzip压缩,将注释去掉开启
keepalive_timeout 65; #设置长连接的超时时间
#虚拟服务器的相关设置
server {
listen 80; #设置监听的端口
server_name localhost; #设置绑定的主机名、域名或ip地址
charset koi8-r; # 设置编码字符
location / {
root /var/www/nginx; #设置服务器默认网站的根目录位置,需要手动创建
index index.html index.htm; #设置默认打开的文档
}
error_page 500 502 503 504 /50x.html; #设置错误信息返回页面
location = /50x.html {
root html; #这里的绝对位置是/usr/local/nginx/html
}
}
}

猜你喜欢

转载自blog.csdn.net/qq_48229321/article/details/109078973