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;
}

最新文章

  1. HDU 5047 推公式+别样输出
  2. IBatisNet基础组件
  3. Codeforces Round #370 (Div. 2) B
  4. Android:修改版本
  5. Java NIO类库Selector机制解析(上)
  6. WIN8重见开始菜单
  7. [MODx] 3. Working with chunks, TV, Category
  8. c#基础学习汇总----------base和this,new和virtual
  9. adb logcat调试中常用的命令介绍
  10. 详解Android ActionBar之一:ActionBar概述与创建
  11. ADB操作多台设备
  12. Find Minimum in Rotated Sorted Array问题的困惑
  13. Peterson算法与Dekker算法解析
  14. oracle表连接------>排序合并连接(Merge Sort Join)
  15. ProductHunt,TechCrunch和AppStore的差的值
  16. 转:web_custom_request应用示例
  17. 1.怎样控制div中的图片居中
  18. FATE
  19. springboot解决跨域问题(Cors)
  20. JavaScript开发工具简明历史

热门文章

  1. linux 下 安装go
  2. Mahout实现的算法
  3. 通过JS模拟select表单,达到美化效果[demo]
  4. Benefits of Using the Spring Framework Dependency Injection 依赖注入 控制反转
  5. redis cluster集群部署
  6. springboot的相关信息
  7. gcc安装多个版本
  8. java一些基本的方法
  9. 如何使用iClap创建普通批注
  10. Educational Codeforces Round 55 (Rated for Div. 2) Solution