一.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主配置文件解析的更多相关文章

  1. Nginx 目录结构、Nginx服务控制命令

    # Nginx目录结构 # 首先推荐一个查看目录结构的工具 tree # yum install -y tree # sudo apt-get install -y tree ubuntu # 查看n ...

  2. FTP服务器中vsftpd主配置文件解析

    /etc/vsftpd/vsftpd.conf#################匿名权限控制############### anonymous_enable=YES #是否启用匿名用户no_anon_ ...

  3. nginx.conf(centos6, 1.12)主配置文件修改

    #nginx1.12 centos6.xuser admin admin;worker_processes 4; error_log /data/services/logs/nginx_error.l ...

  4. web站点放在nginx其他目录下

    web站点放在nginx其他目录下 .查看主配置文件 [root@bogon mysql]# cat /etc/nginx/nginx.conf user root root; worker_proc ...

  5. nginx目录结构和配置文件

    nginx软件功能模块说明 Nginx软件之所以强大,是因为它具有众多的功能模块,下面列出了企业常用的重要模块. (1) Nginx核心功能模块(Core functionality)nginx核心功 ...

  6. Nginx目录结构与配置文件详解

    Nginx安装 具体安装nginx请移步:[nginx部署] 安装依赖 安装pcre依赖软件 [root@ubuntu ~]# yum install -y pcre pcre-devel //外网情 ...

  7. 【Nginx(二)】Nginx目录结构和常用的命令以及核心配置文件

    Nginx的目录结构: 默认的安装路径 : /usr/local/nginx 安装完成后,Nginx的目录结构如下: conf:   #所有配置文件的目录 nginx.conf  #默认的主要配置文件 ...

  8. 二、nginx 安装目录详解

    rpm -ql nginx 路径 类型 介绍 /etc/logrotate.d/nginx  配置文件  Nginx 日志轮转,用于logrotate服务日志切割 /etc/nginx /etc/ng ...

  9. nginx 安装目录详解

    rpm -ql nginx 路径 类型 介绍 /etc/logrotate.d/nginx  配置文件  Nginx 日志轮转,用于logrotate服务日志切割 /etc/nginx /etc/ng ...

随机推荐

  1. 基于SILVACO ATLAS的a-IGZO薄膜晶体管二维器件仿真(05)

    关于特性曲线的输出调整: 初代版本 material material=igzo eg300=3.5 nc300=8.5e21 nv300=8.5e21 taun0=1e-9 taup0=1e-9 a ...

  2. 运维数据同步工具:rsync,serync,csync,drbd,info(基于文件系统)

     Rsync官方站点:http://rsync.samba.org 1. Rsync rsync是一款开源的实现数据全量与增量同步备份的工具 生产环境中使用的场景: 1:一般用于数据异地备份 2:用于 ...

  3. P1579

    AC: #include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for(int i = a; i < b ...

  4. leetCode练题——28. Implement strStr()

    1.题目 28. Implement strStr()——Easy Implement strStr(). Return the index of the first occurrence of ne ...

  5. 彻底解决Spring mvc中时间的转换和序列化等问题

    痛点 在使用Spring mvc 进行开发时我们经常遇到前端传来的某种格式的时间字符串无法用java8的新特性java.time包下的具体类型参数来直接接收. 我们使用含有java.time封装类型的 ...

  6. Ubuntu Rabbitmq 安装与配置

    原文链接:http://blog.csdn.net/rickey17/article/details/72756766 添加源 新增公钥(不加会有警告) 更新源 安装rabbitmq-server e ...

  7. acm数论之旅(转载)---最大公约数与最小公倍数

    gcd(a, b),就是求a和b的最大公约数 lcm(a, b),就是求a和b的最小公倍数 然后有个公式 a*b = gcd * lcm     ( gcd就是gcd(a, b), ( •̀∀•́ ) ...

  8. Bugku-CTF加密篇之easy_crypto(0010 0100 01 110 1111011 11 11111 010 000 0 001101 1010 111 100 0 001101 01111 000 001101 00 10 1 0 010 0 000 1 01111 10 11110 101011 1111101)

    easy_crypto 0010 0100 01 110 1111011 11 11111 010 000 0 001101 1010 111 100 0 001101 01111 000 00110 ...

  9. 模块学习-json pickle

    json json序列化 import json def sayhi(name): print("hello",name) info = { 'name':'mogu', 'age ...

  10. 一大波新款iPhone跟安卓厂商抢夺5G市场

    据外媒最新报道称,苹果已经基本完成了今年iPhone的推新阵容,其发布的多款新机中,将涵盖399美元-1149美元的售价区间,特别是5G手机,起步价可能会很亲民,其目的在于进一步占据市场. 今年苹果将 ...