Centos7 nginx的目录结构与nginx主配置文件解析
一.nginx的目录结构
[root@node nginx_116]# ls
client_body_temp conf fastcgi_temp html logs proxy_temp sbin scgi_temp uwsgi_temp
conf 存放nginx所有配置文件的目录,主要nginx.conf
html 存放nginx默认站点的目录,如index.html、error.html等
logs 存放nginx默认日志的目录,如error.log access.log
sbin 存放nginx主命令的目录,sbin/nginx
二.nginx主配置文件解析
CoreModule核心模块
user www; #Nginx进程所使用的用户
worker_processes ; #Nginx运行的work进程数量(建议与CPU数量一致或auto)
error_log /log/nginx/error.log #Nginx错误日志存放路径
pid /var/run/nginx.pid #Nginx服务运行后产生的pid进程号
events事件模块
events {
worker_connections //每个worker进程支持的最大连接数
use epool; //事件驱动模型, epoll默认
}
http内核模块
//公共的配置定义在http{}
http { //http层开始
...
//使用Server配置网站, 每个Server{}代表一个网站(简称虚拟主机)
'server' {
listen ; //监听端口, 默认80
server_name localhost; //提供服务的域名或主机名
access_log host.access.log //访问日志
//控制网站访问路径
'location' / {
root /usr/share/nginx/html; //存放网站代码路径
index index.html index.htm; //服务器返回的默认页面文件
}
//指定错误代码, 统一定义错误页面, 错误代码重定向到新的Locaiton
error_page /50x.html;
}
...
//第二个虚拟主机配置
'server' {
...
}
include /etc/nginx/conf.d/*.conf; //包含/etc/nginx/conf.d/目录下所有以.conf结尾的文件
} //http层结束
nginx核心配置
#定义nginx工作进程数
worker_processes ;#错误日志
#error_log logs/error.log;
#http定义代码主区域http {
include mime.types;
default_type application/octet-stream;
#定义nginx的访问日志功能
#nginx会有一个accses.log功能,查看用户访问的记录
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 logs/access.log main;
sendfile on;
keepalive_timeout ;
#开启gzip压缩传输 gzip on;
#虚拟主机1 定义一个 斗鱼网站 server {
#定义nginx的访问入口端口,访问地址是 192.168.11.37:
listen ;
#定义网站的域名www.woshidouyu.tv
#如果没有域名,就填写服务器的ip地址 192.168.11.37 server_name www.woshidouyu.tv;
#nginx的url域名匹配
#只要请求来自于www.woshidouyu.tv/
#只要请求来自于www.woshidouyu.tv/qweqwewqe
#最低级的匹配,只要来自于www.woshidouyu.tv这个域名,都会走到这个location
location / {
#这个root参数,也是关键字,定义网页的根目录
#以nginx安装的目录为相对路径 /opt/nginx112/html
#可以自由修改这个root定义的网页根目录 root html;
#index参数定义网站的首页文件名,默认的文件名 index index.html index.htm;
}
#错误页面的优化(只要是遇到前面4系列的错误,就会直接跳转到相对目录下的40x.html页面)
error_page /40x.html;
}
}
Centos7 nginx的目录结构与nginx主配置文件解析的更多相关文章
- Nginx 目录结构、Nginx服务控制命令
# Nginx目录结构 # 首先推荐一个查看目录结构的工具 tree # yum install -y tree # sudo apt-get install -y tree ubuntu # 查看n ...
- FTP服务器中vsftpd主配置文件解析
/etc/vsftpd/vsftpd.conf#################匿名权限控制############### anonymous_enable=YES #是否启用匿名用户no_anon_ ...
- nginx.conf(centos6, 1.12)主配置文件修改
#nginx1.12 centos6.xuser admin admin;worker_processes 4; error_log /data/services/logs/nginx_error.l ...
- web站点放在nginx其他目录下
web站点放在nginx其他目录下 .查看主配置文件 [root@bogon mysql]# cat /etc/nginx/nginx.conf user root root; worker_proc ...
- nginx目录结构和配置文件
nginx软件功能模块说明 Nginx软件之所以强大,是因为它具有众多的功能模块,下面列出了企业常用的重要模块. (1) Nginx核心功能模块(Core functionality)nginx核心功 ...
- Nginx目录结构与配置文件详解
Nginx安装 具体安装nginx请移步:[nginx部署] 安装依赖 安装pcre依赖软件 [root@ubuntu ~]# yum install -y pcre pcre-devel //外网情 ...
- 【Nginx(二)】Nginx目录结构和常用的命令以及核心配置文件
Nginx的目录结构: 默认的安装路径 : /usr/local/nginx 安装完成后,Nginx的目录结构如下: conf: #所有配置文件的目录 nginx.conf #默认的主要配置文件 ...
- 二、nginx 安装目录详解
rpm -ql nginx 路径 类型 介绍 /etc/logrotate.d/nginx 配置文件 Nginx 日志轮转,用于logrotate服务日志切割 /etc/nginx /etc/ng ...
- nginx 安装目录详解
rpm -ql nginx 路径 类型 介绍 /etc/logrotate.d/nginx 配置文件 Nginx 日志轮转,用于logrotate服务日志切割 /etc/nginx /etc/ng ...
随机推荐
- Echarts字体和线条颜色设置操作笔记
在网上偶然看到的一篇文章 感觉不错 下面是原著地址 原著地址:https://blog.csdn.net/eastmount/article/details/52823548
- Ethereum Learning Materials
Home 注:本页为 EthFans 站内文章精选集.鉴于文章的采集范围较广,我们无法保证文章内容没有重复,也不能保证排列的顺序实现了最优的认识路径.我们只能说,这些文章是我们精挑细选后,确认可以长期 ...
- 表与java类关系
总结: 表名对应类名,字段名对应属性名 java:多对多:各自类中添加一个对方类集合的属性 一对多:一的一方添加一个对方类集合的属性 ,多的一方添加一个对方类的属性 一对一:各自类中添加一个对 ...
- template-组件封装
HTML: //:ligit='ligit' 一致 <div id='app'> <template-swiper :ligit='ligit'></template-s ...
- 关于anaconda-navigator打不开的问题
19-10版本的anaconda-navigator打不开,没有图形化界面就是很糟糕 在命令行执行各种命令都没有问题,说明anaconda并没有出现大的问题,可能只是图形化界面出了问题. 执行 ana ...
- P1579
AC: #include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for(int i = a; i < b ...
- 使用MQTTBox连接阿里云平台
这篇只做一个简单的介绍,和上一篇没有根本的区别.只是就两个客户端的差异介绍一下. 一.需要参考的内容: 使用MQTT.fx连接阿里云平台: https://www.cnblogs.com/mhtc/p ...
- Tensorflow机器学习入门——读取数据
TensorFlow 中可以通过三种方式读取数据: 一.通过feed_dict传递数据: input1 = tf.placeholder(tf.float32) input2 = tf.placeho ...
- C:变量的声明与定义
声明变量不需要建立存储空间,如:extern int a; 定义变量需要建立存储空间,如:int b; #include <stdio.h> int main() { //extern 关 ...
- PyQt5设置图片格式及动画
1.缩放图片'''使用QImage.Scale(width,height)方法可以来设置图片'''from PyQt5.QtCore import *from PyQt5.QtGui import * ...