#nginx服务主配置文件nginx.conf的结构
[root@localhost nginx]# grep ^[^#] /etc/nginx/nginx.conf
=========全局配置(无{}标志)=======================
user nginx; #进程所属用户
worker_processes auto; #worker数量
error_log /var/log/nginx/error.log; #错误日志存放路径
pid /run/nginx.pid; #pid文件路径
include /usr/share/nginx/modules/*.conf; #include导入的功能模块配置文件
=========全局配置(无{}标志)=======================
==========性能配置(有{}标志)=================
events {
worker_connections 1024; #TCP连接数
}
==========性能配置(有{}标志)=================
=========http模块配置(有{}标志)==================
http { #http区块开始
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; #开启高效文件传输模式
tcp_nopush on; #性能优化参数
tcp_nodelay on; #性能优化参数
keepalive_timeout 65; #持久连接时间或超时时间
types_hash_max_size 4096; #性能优化参数
include /etc/nginx/mime.types; #可解析的静态资源类型
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf; #子配置文件存放路径
server { #server区块开始
listen 80; #监听端口
listen [::]:80;
server_name _; #服务器的名字
root /usr/share/nginx/html; #主页存放路径
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf; #子配置文件存放路径
error_page 404 /404.html; #404错误返回的页面
location = /40x.html { #使用location定义用户请求的uri
}
error_page 500 502 503 504 /50x.html; #500、502、503、504返回的页面
location = /50x.html {
}
} #server区块结束
} #http区块结束
=========http模块配置(有{}标志)==================
web服务器2
[root@localhost ~]
#systemctl disable firewalld --now
[root@localhost ~]
# setenforce 0
[root@localhost ~]
# getenforce
Permissive
[root@localhost ~]
# systemctl restart nginx
#
测试可以使用
curl
命令访问
web
服务器或者使用浏览器访问
[root@localhost ~]
# curl -I localhost