首先是nginx.conf

vim /etc/nginx/nginx.conf

user  nginx;                      // 设置nginx服务的系统使用用户
worker_processes 1; // 工作进程数 error_log /var/log/nginx/error.log warn; // nginx的错误日志
pid /var/run/nginx.pid; // nginx服务启动时候pid events { // 事件模块,nginx优势利用epoll内核模型,在这里可以配置使用哪个内核模型
worker_connections 1024; // 每个进程允许最大连接数 ,还有个use是工作进程数
} http {
include /etc/nginx/mime.types; //设置contentType
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; // 读到这个地方是加载另一个默认配置配置文件default.conf
} default.conf server {
listen 80;
server_name localhost; #charset koi8-r;
#access_log /var/log/nginx/host.access.log main; location / {
root /usr/share/nginx/html;
index index.html index.htm; // 默认加载根路径文件
} #error_page 404 /404.html; # redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /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;
"/etc/nginx/conf.d/default.conf" 45L, 1093C



http可以包含多个http服务,一个server配置一个独立的站点。一个http可以有多个server,一个server可以有多个location匹配资源路径

nginx(一)之默认配置文件的更多相关文章

  1. nginx新建nginx_fzjh.conf文件,不使用默认配置文件

    worker_processes 4; events{ worker_connections 1024; } http{ server { listen 80; server_name myserve ...

  2. nginx默认配置文件解释

    nginx默认配置文件 nginx.conf 介绍: 全局配置 user  nginx; 设置nginx服务的系统使用用户 worker_processes  1; 工作进程数(建议和CPU核心数保持 ...

  3. 更改 Nginx 服务的默认用户

    为什么要更改 Nginx 服务的默认用户:就像更改 ssh 的默认 22 端口一样,增加安全性,Nginx 服务的默认用户是 nobody ,我们更改为 nginx 1.添加 nginx 用户 use ...

  4. 【转载】Docker 安装 Nginx 并个性化挂载配置文件 nginx.conf

    首先,系统(3.8以上内核的linux)中安装好 Docker 这个运用程序.由于网络原因,我们下载一个Docker官方的镜像需要很长的时间,甚至下载失败.为此,阿里云容器镜像服务提供了官方的镜像站点 ...

  5. Nginx安装、默认虚拟主机、Nginx用户认证和域名重定向

    6月7日任务 12.6 Nginx安装12.7 默认虚拟主机12.8 Nginx用户认证12.9 Nginx域名重定向 扩展nginx.conf 配置详解 http://www.ha97.com/51 ...

  6. Nginx优化之基本安全优化 (隐藏Nginx软件版本号信息,更改源码隐藏Nginx软件名及版本号,更改Nginx服务的默认用户)

    一,隐藏Nginx软件版本号信息 查看版本号 curl -I 192.168.0.220 HTTP/1.1 200 OK Server: nginx/1.6.2 #这里清晰的暴露了Web版本号(1.6 ...

  7. Linux centosVMware Nginx安装、 默认虚拟主机、Nginx用户认证、Nginx域名重定向

    一. Nginx安装 cd /usr/local/src wget http://nginx.org/download/nginx-1.12.1.tar.gz 版本在http://nginx.org/ ...

  8. struts2默认配置文件 struts-default.xml

    注:用的struts2的版本是2.1.6 strtus2的默认配置文件 struts-default.xml ,其中的默认的拦截器,包括其中的拦截器栈. 因为struts2的配置文件struts.xm ...

  9. nginx转发会 默认忽略 headers 中name带”_”的

    昨天遇到一个很蛋疼的问题,在提供的一个 http api中,有定义了一个"X_AUTH_TOKEN"自定义head,可是请求这个api时带上"X_AUTH_TOKEN&q ...

  10. Windows Redis默认配置文件,Redis配置不生效解决方案

    Windows Redis默认配置文件,Redis配置不生效解决方案, Windows Redis自启动配置不生效解决方案,Windows Redis增加自动启动服务 >>>> ...

随机推荐

  1. [C++]PAT乙级1003. 我要通过!(17/20)

    /* 1003. 我要通过!(20) “答案正确”是自动判题系统给出的最令人欢喜的回复.本题属于PAT的“答案正确”大派送 —— 只要读入的字符串满足下列条件,系统就输出“答案正确”,否则输出“答案错 ...

  2. luogu P3312 [SDOI2014]数表

    传送门 我们看要求的东西\[\sum_{i=1}^{n}\sum_{j=1}^{m}[\sigma(gcd(i,j))\le a]\sigma(gcd(i,j))\] 然而\(\le a\)比较烦,可 ...

  3. 【.net ajax显示后台返回值】

    1..net ajax显示后台返回值 <script>        $(document).ready(function () {            $("#btn&quo ...

  4. Kotlin中,lateinit 和 lazy{} 的区别

    1.lazy{} 只能用在val类型, lateinit 只能用在var类型 如 : val name: String by lazy { "sherlbon" }lateinit ...

  5. mysql 与linux ~ 内存分析与调优

    一 简介:linux内存和mysql二 分类   1 用户空间和内核空间      用户空间内存,从低到高分别是五种不同的内存段      1 只读段 包含代码和常量等      2 数据段 包含全局 ...

  6. [转]python3之日期和时间

    转自:https://www.cnblogs.com/zhangxinqi/p/7687862.html#_label6 阅读目录 1.python3日期和时间 2.时间元组 3.获取格式化的时间 4 ...

  7. Linker Scripts3--MEMORY Command

    1.前言 链接器的默认配置允许所有有效内存的分配,你可以使用MEMORY命令来重新定义它 2.MEMORY命令 MEMORY命令描述了一个内存块的位置和大小.你可以用它来描述哪块内存区域可以被链接器使 ...

  8. k64 datasheet学习笔记31---External Bus Interface (FlexBus)

    1.前言 FlexBus多功能外部总线接口控制器是一个硬件模块: (1)通过并行总线提供存储器扩展或与外设连接: (2)如下的同步或异步的slave-only设备可以直连到FlexBus总线或者只需增 ...

  9. ansible 常见指令表

    Play 指令 说明 accelerate 开启加速模式 accelerate_ipv6 是否开启ipv6 accelerate_port 加速模式的端口 always_run   any_error ...

  10. boost::tokenizer详解

    tokenizer 库提供预定义好的四个分词对象, 其中char_delimiters_separator已弃用. 其他如下: 1. char_separator char_separator有两个构 ...