nginx.conf的完整配置说明
#用户 用户组
user www www;
#工作进程,根据硬件调整,有人说几核cpu,就配几个,我觉得可以多一点
worker_processes 5;
#错误日志
error_log logs/error.log;
#pid文件位置
pid logs/nginx.pid;
worker_rlimit_nofile 8192;
events {
#工作进程的最大连接数量,根据硬件调整,和前面工作进程配合起来用,尽量大,但是别把cpu跑到100%就行
worker_connections 4096;
}
http {
include conf/mime.types;
#反向代理配置,可以打开proxy.conf看看
include /etc/nginx/proxy.conf;
#fastcgi配置,可以打开fastcgi.conf看看
include /etc/nginx/fastcgi.conf;
default_type application/octet-stream;
#日志的格式
log_format main ‘$remote_addr – $remote_user [$time_local] $status ‘
‘”$request” $body_bytes_sent “$http_referer” ‘
‘”$http_user_agent” “$http_x_forwarded_for”’;
#访问日志
access_log logs/access.log main;
sendfile on;
tcp_nopush on;
#根据实际情况调整,如果server很多,就调大一点
server_names_hash_bucket_size 128; # this seems to be required for some vhosts
#这个例子是fastcgi的例子,如果用fastcgi就要仔细看
server { # php/fastcgi
listen 80;
#域名,可以有多个
server_name domain1.com www.domain1.com;
#访问日志,和上面的级别不一样,应该是下级的覆盖上级的
access_log logs/domain1.access.log main;
root html;
location / {
index index.html index.htm index.php;
}
#所有php后缀的,都通过fastcgi发送到1025端口上
#上面include的fastcgi.conf在此应该是有作用,如果你不include,那么就把fastcgi.conf的配置项放在这个下面。
location ~ .php$ {
fastcgi_pass 127.0.0.1:1025;
}
}
#这个是反向代理的例子
server { # simple reverse-proxy
listen 80;
server_name domain2.com www.domain2.com;
access_log logs/domain2.access.log main;
#静态文件,nginx自己处理
location ~ ^/(images|javascript.|js|css|flash|media|static)/ {
root /var/www/virtual/big.server.com/htdocs;
#过期30天,静态文件不怎么更新,过期可以设大一点,如果频繁更新,则可以设置得小一点。
expires 30d;
}
#把请求转发给后台web服务器,反向代理和fastcgi的区别是,反向代理后面是web服务器,fastcgi后台是fasstcgi监听进程,当然,协议也不一样。
location / {
proxy_pass http://127.0.0.1:8080;
}
}
#upstream的负载均衡,weight是权重,可以根据机器配置定义权重。据说nginx可以根据后台响应时间调整。后台需要多个web服务器。
|
|
upstream big_server_com { |
|
|
server 127.0.0.3:8000 weight=5; |
|
|
server 127.0.0.3:8001 weight=5; |
|
server 192.168.0.1:8000; |
|
server 192.168.0.1:8001; |
|
} |
|
server { |
|
listen 80; |
|
|
server_name big.server.com; |
|
access_log logs/big.server.access.log main; |
|
location / { |
|
proxy_pass http: //big_server_com; |
|
} |
|
} |
|
} |
—————————————–
Nginx 安置后只有一个法式文件,自己并不供给各类办理法式,它是利用参数和体系旌旗灯号机制对 Nginx 历程自己举行节制的。 Nginx 的参数包罗有如下几个:
-c :利用指定的设置装备摆设文件而不是 conf 目次下的 nginx.conf 。
-t:测试设置装备摆设文件是否准确,在运行时必要从头加载设置装备摆设的时辰,此号令很是主要,用来检测所点窜的设置装备摆设文件是否有语法错误。
-v:表现 nginx 版本号。
-V:表现 nginx 的版本号以及编译情况信息以及编译时的参数。
比方我们要测试某个设置装备摆设文件是否誊写准确,我们可以利用以下号令
sbin/nginx – t – c conf/nginx2.conf
nginx.conf的完整配置说明的更多相关文章
- nginx.conf 集群完整配置
###############################nginx.conf 集群完整配置############################### #user nobody; # user ...
- nginx.conf 完整的集群配置
###############################nginx.conf 整配置############################### #user nobody; # user 主模 ...
- Nginx配置文件(nginx.conf)配置详解(2)
Nginx的配置文件nginx.conf配置详解如下: user nginx nginx ; Nginx用户及组:用户 组.window下不指定 worker_processes 8; 工作进程:数目 ...
- Nginx配置文件(nginx.conf)配置详解
Nginx的配置文件nginx.conf配置详解如下: user nginx nginx ; Nginx用户及组:用户 组.window下不指定 worker_processes 8; 工作进程:数目 ...
- nginx.conf配置及优化相关
nginx.conf配置文件内容 user www www; worker_processes ; worker_rlimit_nofile ; error_log /data/nginx/logs/ ...
- Nginx 之二: nginx.conf 配置及基本优化
一:常用功能优化: 1:网络连接的优化: 只能在events模块设置,用于防止在同一一个时刻只有一个请求的情况下,出现多个睡眠进程会被唤醒但只能有一个进程可获得请求的尴尬,如果不优化,在多进程的ngi ...
- Nginx配置文件nginx.conf中文详解【转】
PS:Nginx使用有两三年了,现在经常碰到有新用户问一些很基本的问题,我也没时间一一回答,今天下午花了点时间,结合自己的使用经验,把Nginx的主要配置参数说明分享一下,也参考了一些网络的内容,这篇 ...
- linux下Nginx配置文件(nginx.conf)配置设置详解(windows用phpstudy集成)
linux备份nginx.conf文件举例: cp /usr/local/nginx/nginx.conf /usr/local/nginx/nginx.conf-20171111(日期) 在进程列表 ...
- /etc/nginx/nginx.conf配置文件详解
user nginx; #数值和cpu核数个数一致worker_processes 8; #worker与cpu绑定 worker_cpu_affinity 0001 0010 0100 1000 1 ...
随机推荐
- [NOIP2018校模拟赛]T1聚会 party
题目链接: 聚会 分析: 设每个点到1号点的距离为dist_{i},每个点的权值为x_{i},目标点到1号点的距离为dist,权值为x,那么对于每一次查询,我们讨论三种情况: ① 目标家庭在区间左边( ...
- git导出代码
1.快速查询 $git archive --format zip --output "./output.zip" master -0 ./output.zip 是生成的文件 mas ...
- 自定义view(13)自定义属性
1.添加attrs.xml文件 在android studio下,在res/values 下新建资源文件attrs.xml 2.添加自定义的属性 在attrs.xml中添加属性,如下.其中format ...
- 转--oracle查看允许的最大连接数和当前连接数等信息
两个参数间的关系:sessions=1.1*processes+5 目前总结的语句,在查看数据的连接情况很有用,写完程序一边测试代码一边查看数据库连接的释放情况有助于分析优化出一个健壮的系统程序来. ...
- Plugging an Unplugged Pluggable Database issue 2
因为原库和目标库版本不一制,出现各种问题,强烈建议保持2个版本一致 http://www.cndba.cn/dave/article/220 Log 提示查看PDB_PLUG_IN_VIOLATION ...
- 洛谷P2761 软件补丁问题(状压DP,SPFA)
题意 描述不清... Sol 网络流24题里面怎么会有状压dp?? 真是狗血,不过还是简单吧. 直接用$f[sta]$表示当前状态为$sta$时的最小花费 转移的时候枚举一下哪一个补丁可以搞这个状态 ...
- 利用伪类写一个自定义checkbox和radio
首先是效果图来一张 再来一张html结构 关键的CSS来了~ 首先呢要把input标签设置为display: none; 因为自定义的原理是通过label的for属性,来点击label转向为点击in ...
- windows session logoff时进行处理动作
目标:Windows session logoff时得到通知,进行一些记录/清理工作 测试平台: win7 x64 logoff时系统会发送WM_ENDSESSION消息,如果某个应用对这个消息的处理 ...
- 螺旋数字的python实现
螺旋数字的算法简单实现. 示例 5 01 02 03 04 05 16 17 18 19 06 15 24 25 20 07 14 23 22 21 08 13 12 11 10 09 通过观察,外部 ...
- Chomp游戏(必胜策略分析)
游戏简介 Chomp是一个双人游戏,有m x n块曲奇饼排成一个矩形格状,称作棋盘. ----两个玩家轮流自选一块还剩下的曲奇饼,而且还要把它右边和下边所有的曲奇饼都取走(如果存在) ----先吃到左 ...