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账户认证功能: 自定义错误页面: 自定义访问日志: 检测文件是否存在: 长连接配置: 作为下载服务器配置: 作为上传服务器: 其他 ...
随机推荐
- 百度地图api定位和导航简写
function locate() { // 百度地图API功能 var map = new BMap.Map("allmap"); // 创建Map实例 var point = ...
- web站点检查简易shell脚本
1.web样式 <h4>THE STATUS OF RS:</h4> <meta http-equiv="> <table border=" ...
- SQL中distinct的用法(转载)
1.作用于单列 2.作用于多列 3.COUNT统计 4.distinct必须放在开头 5.其他 在表中,可能会包含重复值.这并不成问题,不过,有时您也许希望仅仅列出不同(distinct)的值.关键词 ...
- SVN 配置和使用
SVN使用环境 使用SVN管理源代码,必须有2套环境 服务器 用来存储客户端上传的源码 一般都是在Windows环境下安装Visual SVN Server 客户端 用来提交.回退.修改.下载等操作 ...
- AE导出mov
最近安装了AE发现没法导出MOV格式的: 感觉应该是没有安装支持MOV的播放器之类的原因造成的:果断去下载一个quicktime 安装好之后重启发现真的有 mov 格式了
- Hadoop生态上几个技术的解释:hive、pig、hbase 关系与区别
hadoop生态圈 Pig 一种操作hadoop的轻量级脚本语言,最初又雅虎公司推出,不过现在正在走下坡路了.当初雅虎自己慢慢退出pig的维护之后将它开源贡献到开源社区由所有爱好者来维护.不过现在还是 ...
- Oracle Schema Objects——Synonyms
Oracle Schema Objects 同义词 同义词 = 表的别名. 现在假如说有一张数据表的名称是“USER1.student”,而现在又为这张数据表起了一个“USER1”的名字,以后就可以直 ...
- SQL基础--查询之四--集合查询
SQL基础--查询之四--集合查询
- Drawing Graphs using Dot and Graphviz
Drawing Graphs using Dot and Graphviz Table of Contents 1. License 2. Introduction 2.1. What is DOT? ...
- 003-and design-在create-react-app项目中使用antd
一.概述 create-react-app 是业界最优秀的 React 应用开发工具之一,本文会尝试在 create-react-app 创建的工程中使用 antd 组件,并自定义 webpack 的 ...