nginx.conf配置文件

本文介绍了如何进入并查看nginx配置文件。重点在于nginx.conf,它是主配置文件,包含用户、进程数、错误日志路径、PID路径等设置。此外,还涉及到events模块的最大连接数,http服务器的设置如日志格式、访问日志路径、高效传输模式和长连接超时时间等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

nginx.conf配置文件

首先我们进入到cd etc/nginx.然后通过ls查看nginx目录的相关内容。在nginx目录下,我们需要关注nginx.conf文件,这个文件是我们的主配置文件,cat打开:

cat nginx.conf

 

# 运行用户,默认是nginx

user  nginx;

# nginx进程数,一般设置为和cpu核数一样

worker_processes  1;

 

# 全局错误日志路径

error_log  /var/log/nginx/error.log warn;

# 进程pid路径

pid        /var/run/nginx.pid;

 

 

events {

# 最大连接数

    worker_connections  1024;

}

 

 

# 设置http服务器

http {

    include       /etc/nginx/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;

    #tcp_nopush     on;

# 长连接超时时间,单位是秒

    keepalive_timeout  65;

#传输时是否压缩,压缩的话需要解压,但是传的大小就小了

    #gzip  on;

#加载其他的配置文件,一带多

    include /etc/nginx/conf.d/*.conf;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值