nginx.conf 配置详解
nginx主配置文件中的内容
pid
主线程id的存储位置。
# cat /usr/local/nginx/logs/nginx.pid
1113
# pgrep -o nginx
1113
user
使用这个参数来配置 worker 进程的用户和组。如果忽略 group ,那么group 的名 字等于该参数指定用户的用户组。
# ps -ef | grep nginx
root 1113 1 0 12月08 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
www 1118 1113 0 12月08 ? 00:00:00 nginx: worker process
www 1119 1113 0 12月08 ? 00:00:00 nginx: worker process
www 1120 1113 0 12月08 ? 00:00:00 nginx: worker process
www 1121 1113 0 12月08 ? 00:00:01 nginx: worker process
error_log
错误日志的位置。
worker_connections
该指令配置一个工作进程能够接受并发连接的最大数。
include
在 Nginx 的配置文件中, include 文件可以在任何地方,以便增强配置文件的可读性,并且能够使得部分配置文件重新使用。
include vhost/*.conf;
http
include mime.types; #文件扩展名与文件类型映射表
default_type application/octet-stream; #默认文件类型
sendfile on; #开启高效文件传输模式,sendfile指令指定nginx是否调用sendfile函数来 输出文件,对于普通应用设为 on,如果用来进行下载等应用磁盘IO重负载应用,可设置 为off,以平衡磁盘与网络I/O处理速度,降低系统的负载。注意:如果图片显示不正常 把这个改成off。
autoindex on; #开启目录列表访问,合适下载服务器,默认关闭。
tcp_nopush on; #防止网络阻塞
tcp_nodelay on; #防止网络阻塞
keepalive_timeout 120; #长连接超时时间,单位是秒
gzip on; #开启gzip压缩输出
server
虚拟主机
实现一台计算机对外提供多个web服务。
其中nginx.conf中的server是默认的server。
server
{
listen 80;
#listen [::]:80 default_server ipv6only=on;
server_name localhost;
index index.html index.htm index.php;
root /home/wwwroot/default/;
#error_page 404 /404.html;
# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
include enable-php.conf;
location /nginx_status
{
stub_status on;
access_log off;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /.well-known {
allow all;
}
location ~ /\.
{
deny all;
}
access_log /home/wwwlogs/access.log;
}
nginx.conf 配置详解的更多相关文章
- nginx.conf配置详解
######Nginx配置文件nginx.conf中文详解##### #定义Nginx运行的用户和用户组 user www www; #nginx进程数,建议设置为等于CPU总核心数. worker_ ...
- ubuntu 13.04 nginx.conf 配置详解
1.nginx.conf 文件,路径为:/etc/nginx/agin.conf #使用的用户和组 user www-data; #指定工作衍生进程数(一般等于CPU总核数或总核数的两倍) worke ...
- Nginx的配置文件nginx.conf配置详解
user nginx nginx; #Nginx用户及组:用户 组.window下不指定 worker_processes 8; #工作进程:数目.根据硬件调整,通常等于CPU数量或者2倍于CPU. ...
- Nginx_配置文件nginx.conf配置详解
user nginx nginx ; # Nginx用户及组:用户 组.window下不指定 worker_processes 8; # 工作进程:数目.根据硬件调整,通常等于CPU数量或者2倍于CP ...
- Nginx安全相关配置和nginx.conf中文详解
一.centos下redis安全相关 1.背景 在使用云服务器时,如果我们的redis关闭了protected-mode模式,被病毒攻击的可能会大大增加,因此我们使用redis时候,最好更改默认端口, ...
- Nginx配置文件nginx.conf中文详解(转)
######Nginx配置文件nginx.conf中文详解##### #定义Nginx运行的用户和用户组 user www www; #nginx进程数,建议设置为等于CPU总核心数. worker_ ...
- Nginx配置文件nginx.conf中文详解【转】
PS:Nginx使用有两三年了,现在经常碰到有新用户问一些很基本的问题,我也没时间一一回答,今天下午花了点时间,结合自己的使用经验,把Nginx的主要配置参数说明分享一下,也参考了一些网络的内容,这篇 ...
- Nginx 配置文件nginx.conf中文详解
######Nginx配置文件nginx.conf中文详解##### #定义Nginx运行的用户和用户组 user www www; #nginx进程数,建议设置为等于CPU总核心数. worker_ ...
- Nginx 核心配置详解
目录 Nginx 核心配置详解 Nginx 四层访问控制: Nginx账户认证功能: 自定义错误页面: 自定义访问日志: 检测文件是否存在: 长连接配置: 作为下载服务器配置: 作为上传服务器: 其他 ...
随机推荐
- yii2 的 Url::to() 和 Url::toRoute()
关于Url类的操作在这个页面http://www.yiichina.com/doc/guide/2.0/helper-url: Url::to() 和 toRoute() 非常类似.这两个方法的唯一区 ...
- T-SQL备份数据库恢复
注:此操作在master数据库上执行 /*1.--得到数据库的文件目录 @dbname 指定要取得目录的数据库名 如果指定的数据不存在,返回安装SQL时设置的默认数据目录 如果指定NULL,则返回默认 ...
- Drools规则引擎
一.简介 Drools is a Business Rules Management System (BRMS) solution. It provides a core Business Rules ...
- Django - Ajax - 参数
一.Jquery实现Ajax url type data success error complete statusCode {% load staticfiles %} < ...
- Hotel---poj3667(线段树区间问题)
题目链接:http://poj.org/problem?id=3667 题意:酒店有n个房间,现有m个团队,每个团队需要连续 d 个房间,现在有两个操作,1:需要 d 个房间,2:从 x 开始连续 d ...
- 001-spring cache 简介
一.概述 参看地址: 自3.1版以来,Spring Framework提供了对现有Spring应用程序透明地添加缓存的支持.与事务支持类似,缓存抽象允许一致地使用各种缓存解决方案,而对代码的影响最小. ...
- 表单(上)EasyUI Form 表单、EasyUI Validatebox 验证框、EasyUI Combobox 组合框、EasyUI Combo 组合、EasyUI Combotree 组合树
EasyUI Form 表单 通过 $.fn.form.defaults 重写默认的 defaults. 表单(form)提供多种方法来执行带有表单字段的动作,比如 ajax 提交.加载.清除,等等. ...
- (转)SpringBoot非官方教程 | 第十二篇:springboot集成apidoc
首先声明下,apidoc是基于注释来生成文档的,它不基于任何框架,而且支持大多数编程语言,为了springboot系列的完整性,所以标了个题. 一.apidoc简介 apidoc通过在你代码的注释来生 ...
- jQuery-添加、移出事件
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...
- 零碎收集cocos知识
Configuration类 返回环境变量 local function menuCallback(tag, pSender) printInfo("selected item tag:%d ...