web服务器2

#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模块配置(有{}标志)==================

[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
  • 12
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值