nginx默认配置文件解释
nginx默认配置文件 nginx.conf 介绍:
| 全局配置 | user nginx; | 设置nginx服务的系统使用用户 |
| worker_processes 1; | 工作进程数(建议和CPU核心数保持一致) | |
| error_log /var/log/nginx/error.log warn; | 错误日志。 'warn'代表级别 | |
| pid /var/run/nginx.pid; | 服务启动时候的pid | |
| events { | ||
| worker_connections 1024; | 每个进程允许最大连接数(一般1W左右可满足大部分企业需求) | |
| } | ||
| http { | ||
| include /etc/nginx/mime.types; | ||
| default_type application/octet-stream; | ||
| log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | 日志格式,名字为'main',后面的"$XXX"为日志字段 | |
| '$status $body_bytes_sent "$http_referer" ' | $remote_addr:用户IP、$request:请求的方法、$http_referer:referer值 | |
| '"$http_user_agent" "$http_x_forwarded_for"'; | ||
| access_log /var/log/nginx/access.log main; | 访问日志路径。'main'代表相应log_format名字 | |
| sendfile on; | 这个可以提高读取静态文件效率。 开启它之后用户访问静态文件时将直接通过系统内核将文件放入socket,而不是打开文件再将数据放入socket | |
| #tcp_nopush on; | senffile开启的情况下,提高数据包的传输效率。 即:攒够一定量的包再一起发送,而不是来一个包发一个包 | |
| keepalive_timeout 65; | ||
| #gzip on; | 是否支持压缩 | |
| include /etc/nginx/conf.d/*.conf; | 这句话就将其他配置文件都包含进来了 | |
| } |
nginx默认配置文件 default.conf介绍:
| server { | 子server,可以理解为一个server为一台虚拟服务器 |
| listen 80; | 侦听端口 |
| server_name localhost; | 域名 当一台nginx服务器提供多个域名服务且端口都一样时可以根据用户访问的域名来判断是否应该使用这个server(可以理解为7层的路由),如果用户访问的是app.cctv.com,而这里配的是tv.cctv.com则不会使用该server。 |
| #charset koi8-r; | |
| #access_log /var/log/nginx/host.access.log main; | |
| location / { | 一个server里面可以有多个location。‘/’代表不管访问主页还是子路径都进入这个location进行访问 |
| root /usr/share/nginx/html; | ‘root’是存放首页的路径。 |
| index index.html index.htm; | ‘index’用来指定首页文件,首选index.html,如果没有找到就选index.htm(类似DNS的主备)。 |
| } | |
| #error_page 404 /404.html; | |
| # redirect server error pages to the static page /50x.html | |
| # | |
| error_page 500 502 503 504 /50x.html; | 如果状态码为500 502 503 504则返回/50x.html页面 |
| location = /50x.html { | 定义50x.html的路径 |
| root /usr/share/nginx/html; | |
| } | |
| # proxy the PHP scripts to Apache listening on 127.0.0.1:80 | |
| # | |
| #location ~ \.php$ { | |
| # proxy_pass http://127.0.0.1; | |
| #} | |
| # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 | |
| # | |
| #location ~ \.php$ { | |
| # root html; | |
| # fastcgi_pass 127.0.0.1:9000; | |
| # fastcgi_index index.php; | |
| # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; | |
| # include fastcgi_params; | |
| #} | |
| # deny access to .htaccess files, if Apache's document root | |
| # concurs with nginx's one | |
| # | |
| #location ~ /\.ht { | |
| # deny all; | |
| #} | |
| } |
nginx默认配置文件解释的更多相关文章
- Apache之默认配置文件解释
一.默认配置文件 # 定义apache运行的目录,即程序所在的位置 ServerRoot "/usr/local/apache2" # 定义Apache服务监听的端口 Listen ...
- nginx新建nginx_fzjh.conf文件,不使用默认配置文件
worker_processes 4; events{ worker_connections 1024; } http{ server { listen 80; server_name myserve ...
- Nginx安装及配置文件解释
安装nginx,还是在mac上面用brew比较方便. 首先,brew install nginx,提示改权限 sudo chown -R $(whoami) /usr/local 然后brew ins ...
- nginx之旅(第一篇):nginx下载安装、nginx启动与关闭、nginx配置文件详解、nginx默认网站
一.nginx下载安装 版本nginx 1.15.5 系统环境centos7.5(本机ip192.168.199.228) 关闭selinux 和防火墙firewall 1.下载 wget http: ...
- Nginx.conf配置文件默认配置块略解
#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #erro ...
- 更换nginx默认端口以及配置文件位置
前言 近段时间在准备毕业设计的前期准备,基本确定了前后端分离的架构,于是就需要用到了nginx. 在之前nginx是放在docker上,所以没有端口更改跟配置文件配置的烦恼.但是现在是直接放在服务器上 ...
- 【nginx运维基础(2)】Nginx的配置文件说明及虚拟主机配置示例
配置文件说明 #定义Nginx运行的用户和用户组 user www www; #nginx进程数,建议设置为当前主机的CPU总核心数. worker_processes 8; #全局错误日志定义类型, ...
- Nginx的配置文件(nginx.conf)解析和领读官网
步骤一:vi nginx.conf配置文件,参考本博文的最下面总结,自行去设置 最后nginx.conf内容为 步骤二:每次修改了nginx.conf配置文件后,都要reload下. index.ht ...
- nginx详细配置文件 (转)
Nginx的代码是由一个核心和一系列的模块组成, 核心主要用于提供Web Server的基本功能,以及Web和Mail反向代理的功能:还用于启用网络协议,创建必要的运行时环境以及确保不同的模块之间平滑 ...
随机推荐
- CSAPP 2-2 整数的表示和运算
目录 1 整数表示 1 整数表示 编码整数有2种方式: 一种只能表示非负数(大于0的数), 另一种能够表示负数.零和正数. (1) 整型数据类型: C和C++都支持有符号(默认)和无符号数, Java ...
- Hadoop HA 架构
为什么要用集群? 企业里面,多台机器 伪分布式 每一个角色都是一个进程 HDFS: NN SNN DN YARN: RM NM 大数据所有组件, 都是主从架构 master-slave HDFS读写请 ...
- Linux:VIM编辑器的使用
打开vim编辑器 命令格式: vim 文件路径 vim编辑器的工作模式 进入编辑器后 默认为命令模式 进入输入模式 a 在光标后插入 o 换行插入 i 在光标前插入 返回命令模式 esc 键 进入末行 ...
- Ubuntu笔记本安装高级电源管理工具TLP
Ubuntu系统下的笔记本电脑电量总是下降的很快,尽管目前系统对电源管理的优化已经进步了不少,但还是需要一些工具来辅助. TLP是一款Linux下的高级电源管理工具,相信很多Linux用户会用到它. ...
- 队列Queue的实现
数组实现 package DataStructures.Queues; /** * This implements Queues by using the class Queue. * <p&g ...
- Java Web 学习(8) —— Spring MVC 之文件上传与下载
Spring MVC 之文件上传与下载 上传文件 表单: <form action="upload" enctype="multipart/form-data&qu ...
- Codeforces Round #594 (Div. 2) A. Integer Points 水题
A. Integer Points DLS and JLS are bored with a Math lesson. In order to entertain themselves, DLS to ...
- eclipse3.7以后编译代码提示ambiguous 的解决方法
Eclispe3.7以后在使用可变函数时可能会遇到这种编译错误的问题 The method is ambiguous 正确的解决方法是: 在eclipse.ini -vmargs后面添加 -Dto ...
- Java类加载机制以及双亲委派模型
一.Java类加载机制 1.概述 Class文件由类装载器装载后,在JVM中将形成一份描述Class结构的元信息对象,通过该元信息对象可以获知Class的结构信息:如构造函数,属性和方法等,Java允 ...
- 融云技术分享:解密融云IM产品的聊天消息ID生成策略
本文来自融云技术团队原创分享,原文发布于“融云全球互联网通信云”公众号,原题<如何实现分布式场景下唯一 ID 生成?>,即时通讯网收录时有部分改动. 1.引言 对于IM应用来说,消息ID( ...