nginx配置练习
Nginx配置练习
文件配置结构
main
events {}
http {
server {
location {}
}
}
执行顺序从外到内
指令配置最佳实践
main模块
//worker进程数目和内核相关,几个内核机几个进程
worker_processes auto;
events模块
// nginx单个进程最大并发连接数
worker_processes 1024;
http模块
// 加载其他目录下的配置文件, 一般用来加载目录下不同项目的*.conf,
include /etc/nginx/*.conf;
// response的相应数据流类型
default_type application/json;
// 长连接超时时间
keepalive_timeout 60;
server模块
//监听端口
listen 80
// 设置虚拟的服务地址,来区分不同的服务
server_name zhegepianyi.site;
// server根目录路径
root /var/www;
// 默认的请求文件
index index.html
// 自定义错误页面
error_page
location模块
本作品采用《CC 协议》,转载必须注明作者和本文链接