一.nginx.conf配置结构
1.1配置结构图

1.2 nginx中配置nginx.conf配置内容
#user nobody;
user root; # 表示worker进程是有root用户去执行的
worker_processes 2;
events {# 默认使用epolluse epoll;# 每个worker链接最大数据worker_connections 1024;
}
http {include mime.types;default_type application/octet-stream;sendfile on;keepalive_timeout 65;server {listen 80;server_name localhost;location / {root html;index index.html index.htm;}error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}}
}
二. nginx.conf配置详解
2.1 user root; ======>使用worker进行使用root用户去执行
# 表示worker进程是有root用户去执行的
user root;
worker_processes 2;
events {# 默认使用epolluse epoll;# 每个worker链接最大数据worker_connections 1024;
}
http {include mime.types;default_type application/octet-stream;sendfile on;keepalive_timeout 65;server {# ...}
}

2 .2 events ======>配置worker进程最大连接数和worker进程的工作模式配置,可以提供nginx并发数。

2.3 http ===>>>>>网络相关传输模块配置
http {include mime.types; #1.导入外部文件default_type application/octet-stream;sendfile on; #2.打开文件高效传输的,默认是打开的#tcp_nopush on; #3.这个是需要和sendfile配合一起使用,它的意思是数据包累计到一定大小的时候才发送。keepalive_timeout 65; #4.客户端连接到服务器的超时时间【超过的时间就会关闭,如果有新的客户端连接发现有,没有关闭的连接就会直接使用不要重新连了】#gzip on; #5.开启后发现css,js等数据,就会就行压缩.server {listen 80;server_name localhost;location / {root html;index index.html index.htm;}error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}}#6.导入一个外部的配置文件include oa.conf;
}# oa.conf具体内容如下: >>>>>注意oa.conf和nginx.conf在同一个目录下<<<<
server {listen 89;server_name localhost;location / {root html;index oa.html index.htm;}
}