1.1

Nginx优化分类

1.2

Nginx安全优化

1.2.1

隐藏nginx版本信息优化

1.2.2

修改nginx版本信息

1.2.3

修改worker进程的用户

1.2.4

上传文件大小的限制(动态应用)

1.2.5

站点 Nginx站点目录及文件URL访问控制

1.2.6

配置Nginx,禁止非法域名解析访问企业网站

1.2.7

Nginx图片及目录防盗链解决方案

<span style="color: #000000;">
   惨绿少年的博客!
</span>

我的博客是 <a href="http://www.nmtui.com" target="_blank">博客地址 "http://www.nmtui.com/clsn.jpg">

1.2.8

NGINX错误页面友好显示

1.2.9

Nginx站点目录文件及目录权限优化

  <td style="width: 42.32%; border-top: solid #A5A5A5 1.0pt; mso-border-top-themecolor: accent3; border-left: none; border-bottom: solid #A5A5A5 1.0pt; mso-border-bottom-themecolor: accent3; border-right: none; mso-border-top-alt: solid #A5A5A5 .5pt; mso-border-bottom-alt: solid #A5A5A5 .5pt; background: #A5A5A5; mso-background-themecolor: accent3; padding: 0cm 5.4pt 0cm 5.4pt;" width="42%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 1;">
      <strong><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; color: white; mso-themecolor: background1;">权限处理</span></strong>
    </p>
  </td>
  
  <td style="width: 33.32%; border: solid #A5A5A5 1.0pt; mso-border-themecolor: accent3; border-left: none; mso-border-top-alt: solid #A5A5A5 .5pt; mso-border-top-themecolor: accent3; mso-border-bottom-alt: solid #A5A5A5 .5pt; mso-border-bottom-themecolor: accent3; mso-border-right-alt: solid #A5A5A5 .5pt; mso-border-right-themecolor: accent3; background: #A5A5A5; mso-background-themecolor: accent3; padding: 0cm 5.4pt 0cm 5.4pt;" width="33%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 1;">
      <strong><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; color: white; mso-themecolor: background1;">安全系数</span></strong>
    </p>
  </td>
</tr>

<tr style="mso-yfti-irow: 0;">
  <td style="width: 24.36%; border: solid #C9C9C9 1.0pt; mso-border-themecolor: accent3; mso-border-themetint: 153; border-top: none; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; background: #EDEDED; mso-background-themecolor: accent3; mso-background-themetint: 51; padding: 0cm 5.4pt 0cm 5.4pt;" width="24%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 68;">
      <strong><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">动态</span></strong><strong><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">Web</span></strong><strong><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">集群</span></strong>
    </p>
  </td>
  
  <td style="width: 42.32%; border-top: none; border-left: none; border-bottom: solid #C9C9C9 1.0pt; mso-border-bottom-themecolor: accent3; mso-border-bottom-themetint: 153; border-right: solid #C9C9C9 1.0pt; mso-border-right-themecolor: accent3; mso-border-right-themetint: 153; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-left-alt: solid #C9C9C9 .5pt; mso-border-left-themecolor: accent3; mso-border-left-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; mso-border-themecolor: accent3; mso-border-themetint: 153; background: #EDEDED; mso-background-themecolor: accent3; mso-background-themetint: 51; padding: 0cm 5.4pt 0cm 5.4pt;" width="42%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 64;">
      <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">目录权限</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">755</span>
    </p>
    
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 64;">
      <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">文件权限</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">644</span>
    </p>
    
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 64;">
      <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">所用的目录,以及文件用户和组都是</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">root</span>
    </p>
  </td>
  
  <td style="width: 33.32%; border-top: none; border-left: none; border-bottom: solid #C9C9C9 1.0pt; mso-border-bottom-themecolor: accent3; mso-border-bottom-themetint: 153; border-right: solid #C9C9C9 1.0pt; mso-border-right-themecolor: accent3; mso-border-right-themetint: 153; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-left-alt: solid #C9C9C9 .5pt; mso-border-left-themecolor: accent3; mso-border-left-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; mso-border-themecolor: accent3; mso-border-themetint: 153; background: #EDEDED; mso-background-themecolor: accent3; mso-background-themetint: 51; padding: 0cm 5.4pt 0cm 5.4pt;" width="33%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 64;">
      <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">环境为</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">Nginx+PHP<span style="mso-tab-count: 1;">   </span></span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">文件不能被改,目录不能被写入,安全系数</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">10</span>
    </p>
  </td>
</tr>

<tr style="mso-yfti-irow: 1;">
  <td style="width: 24.36%; border: solid #C9C9C9 1.0pt; mso-border-themecolor: accent3; mso-border-themetint: 153; border-top: none; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="24%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 4;">
      <strong><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">static</span></strong><strong><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">图片集群</span></strong>
    </p>
  </td>
  
  <td style="width: 42.32%; border-top: none; border-left: none; border-bottom: solid #C9C9C9 1.0pt; mso-border-bottom-themecolor: accent3; mso-border-bottom-themetint: 153; border-right: solid #C9C9C9 1.0pt; mso-border-right-themecolor: accent3; mso-border-right-themetint: 153; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-left-alt: solid #C9C9C9 .5pt; mso-border-left-themecolor: accent3; mso-border-left-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; mso-border-themecolor: accent3; mso-border-themetint: 153; padding: 0cm 5.4pt 0cm 5.4pt;" width="42%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt;">
      <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">目录权限</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">755</span>
    </p>
    
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt;">
      <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">文件权限</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">644</span>
    </p>
    
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt;">
      <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">所用的目录,以及文件用户和组都是</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">root</span>
    </p>
  </td>
  
  <td style="width: 33.32%; border-top: none; border-left: none; border-bottom: solid #C9C9C9 1.0pt; mso-border-bottom-themecolor: accent3; mso-border-bottom-themetint: 153; border-right: solid #C9C9C9 1.0pt; mso-border-right-themecolor: accent3; mso-border-right-themetint: 153; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-left-alt: solid #C9C9C9 .5pt; mso-border-left-themecolor: accent3; mso-border-left-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; mso-border-themecolor: accent3; mso-border-themetint: 153; padding: 0cm 5.4pt 0cm 5.4pt;" width="33%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt;">
      <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">环境为</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">Nginx<span style="mso-tab-count: 1;">    </span></span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">文件不能被改,目录不能被写入,安全系数</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">10</span>
    </p>
  </td>
</tr>

<tr style="mso-yfti-irow: 2; mso-yfti-lastrow: yes;">
  <td style="width: 24.36%; border: solid #C9C9C9 1.0pt; mso-border-themecolor: accent3; mso-border-themetint: 153; border-top: none; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; background: #EDEDED; mso-background-themecolor: accent3; mso-background-themetint: 51; padding: 0cm 5.4pt 0cm 5.4pt;" width="24%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 68;">
      <strong><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">上传</span></strong><strong><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">upload</span></strong><strong><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">集群</span></strong>
    </p>
  </td>
  
  <td style="width: 42.32%; border-top: none; border-left: none; border-bottom: solid #C9C9C9 1.0pt; mso-border-bottom-themecolor: accent3; mso-border-bottom-themetint: 153; border-right: solid #C9C9C9 1.0pt; mso-border-right-themecolor: accent3; mso-border-right-themetint: 153; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-left-alt: solid #C9C9C9 .5pt; mso-border-left-themecolor: accent3; mso-border-left-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; mso-border-themecolor: accent3; mso-border-themetint: 153; background: #EDEDED; mso-background-themecolor: accent3; mso-background-themetint: 51; padding: 0cm 5.4pt 0cm 5.4pt;" width="42%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 64;">
      <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">目录权限</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">755</span>
    </p>
    
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 64;">
      <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">文件权限</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">644</span>
    </p>
    
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 64;">
      <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">所用的目录,以及文件用户和组都是</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">root</span>
    </p>
  </td>
  
  <td style="width: 33.32%; border-top: none; border-left: none; border-bottom: solid #C9C9C9 1.0pt; mso-border-bottom-themecolor: accent3; mso-border-bottom-themetint: 153; border-right: solid #C9C9C9 1.0pt; mso-border-right-themecolor: accent3; mso-border-right-themetint: 153; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-left-alt: solid #C9C9C9 .5pt; mso-border-left-themecolor: accent3; mso-border-left-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; mso-border-themecolor: accent3; mso-border-themetint: 153; background: #EDEDED; mso-background-themecolor: accent3; mso-background-themetint: 51; padding: 0cm 5.4pt 0cm 5.4pt;" width="33%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 64;">
      <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">特别:用户上传的目录设置为</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">755</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">,用户和组使用</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">Nginx</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">服务配置的用户</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;"><span style="mso-tab-count: 1;">     </span></span>
    </p>
    
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 64;">
      <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">文件不能被改,目录不能被写入,但是用户上传的目录允许写入文件且需要通过</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">Nginx</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">的其他功能来禁止读文件,安全系数</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">8</span>
    </p>
  </td>
</tr>

1.2.10

Nginx防爬虫优化

1.2.11

利用Nginx限制HTTP的请求方法

1.2.12

使用普通用户启动nginx

1.3

Nginx性能优化

1.3.1

优化nginx worker进行个数

1.3.2

绑定不同的nginx进程到不同的CPU

1.3.3

优化nginx事件处理模型

1.3.4

调整nginx单个进程允许的客户端最大连接数

1.3.5

配置Nginx worker进程最大打开文件数

1.3.6

优化nginx高效文件传输模式

Default: tcp_nodelay on; Context: http, server, location

<p class="a4">
    此选项仅仅当开启sendfile时才生效, 激活这个.tcp_nopush参数可以允许把http response header和响应数据文件的开始部分放在一个文件里发布,其积极的作用是减少网络报文段的数量。
</p>
<span lang="EN-US" style="mso-fareast-font-family: 'Courier New'; mso-bidi-font-family: 'Courier New';"><span style="mso-list: Ignore;">1.3.7 </span></span><!--[endif]-->

<span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">设置</span><span lang="EN-US">nginx</span><span style="mso-bookmark: _Toc507528121;"><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">服务超时参数</span></span></span>

default:keepalive_timeout 75s;#<==参数默认大小 context:http,server,location #<==可以放置的标签段

default:client_header_timeout 60s; #<==参数默认大小 context:http,server #<==可以放置的标签段

default:client_body_timeout 60s; #<==默认值是60秒 context:http,server,location #<==可以放置的标签段

default:send_timeout 60s; #<==默认值是60秒 context:http,server,location #<==可以放置的标签段

<span lang="EN-US" style="mso-fareast-font-family: 'Courier New'; mso-bidi-font-family: 'Courier New';"><span style="mso-list: Ignore;">1.3.8 </span></span><!--[endif]-->

<span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">配置</span><span lang="EN-US">Nginx gzip</span><span style="mso-bookmark: _Toc507528122;"><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">压缩实现性能优化</span></span></span>
<p class="MsoNormal" style="margin-left: 30px;">
  <span style="background-color: initial;">  发送给用户的内容小了,用户访问单位大小的页面就加快了,用户体验提升了,网站口碑就好了。</span>
</p>

<p class="MsoNormal" style="margin-left: 30px;">
   节约网站带宽成本:
</p>

<p class="MsoNormal" style="margin-left: 30px;">
     数据是压缩传输的,因此节省了网站的带宽流量成本,不过压缩时会稍 微消耗一些CPU资源,这个一般可以忽略。
</p>

gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.1; gzip_comp_level 4; gzip_types text/css text/xml application/javascript; gzip_vary on;

#<==开启gzip压缩功能。 gzip_min_length lk; #<==设置允许压缩的页面最小宇节数,页面宇节数从header头的Content-Length中获取。默认值是0,表示不管页面多大都进行压缩。建议设置成大于1K,如果小于1K可能会越压越大。 gzip_buffers 4 16k; #<==压缩缓冲区大小。表示申请4个单位为16K的内存作为压缩结果流缓存,默认值是申请与原始数据 大小相同的内存空间来存储gzip压缩结果。 gzip_http_version 1.1 ; #<==压缩版本(默认1.1,前端为squid2.5时使用1.0),用于设置识别HTTP协议版本,默认是1.1, 目前大部分浏览器已经支持GZIP解压,使用默认即可。 gzip_comp_level 2 ; #<==压缩比率。用来指定gzip压缩比,1压缩比最小,处理速度最快;9压缩比最大,传输速度快,但处理最慢,也比较消耗CPU资源。 gzip_types text/plain application/x-javascript text/css application/xml ; #<==用来指定压缩的类型,“text/html"类型总是会被压缩,这个就是HTTP原理部分讲的媒体类型。 gzip_vary on ; #<==vary header支持。该选项可以让前端的缓存服务器缓存经过gzip压缩的页面,例如用Squid缓存 经过Nginx压缩的数据。

<span lang="EN-US" style="mso-fareast-font-family: 'Courier New'; mso-bidi-font-family: 'Courier New';"><span style="mso-list: Ignore;">1.3.9 </span></span><!--[endif]-->

<span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">配置</span><span lang="EN-US">Nginx expires</span><span style="mso-bookmark: _Toc507528123;"><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">缓存实现性能优化</span></span></span>

server { listen 80; server_name blog.etiantian.org; server_tokens off; # 静态请求处理的location location / { root html/blog; index index.php index.html index.htm; } # 动态请求处理的location location ~* ..(php|php5)?$ { root html/blog; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } location ~ ..(gif|jpg|jpeg|png|bmp|swf)$ { expires 10y; root html/blog; } location ~ .*.(js|css)$ { expires 30d; root html/blog; } }

location / { expires 3650d; }

<span lang="EN-US" style="mso-fareast-font-family: 'Courier New'; mso-bidi-font-family: 'Courier New';"><span style="mso-list: Ignore;">1.3.10 </span></span><!--[endif]-->

<span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">配置</span><span lang="EN-US">FastCGI</span><span style="mso-bookmark: _Toc507528124;"><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">优化</span></span></span>

worker_processes 4; worker_cpu_affinity 0001 0010 0100 1000; worker_rlimit_nofile 65535; user nginx; events { use epoll; worker_connections 10240; } http { include mime.types; default_type application/octet-stream; sendfile on; tcp_nopush on; keepalive_timeout 65; tcp_nodelay on; client_header_timeout 15; client_body_timeout 15; send_timeout 15; log_format main $remote_addr - $remote_user [$time_local] “$request” $status $body_bytes_sent “$http_referer” "$http_user_agent” “$http_x_forwarded_for”; server_tokens off; fastcgi_connect_timeout 240; fastcgi_send_timeout 240; fastcgi_read_timeout 240; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 128k; #fastcgi_temp_path /data/ngx_fcgi_tmp; fastcgi_cache_path /data/ngx_fcgi_cache levels=2:2 keys_zone=ngx_fcgi_cache:512m inactive=1d max_size=40g; #web…………… server { listen 80; server_name blog.nmtui.com; root html/blog; location / { root html/blog; index index.php index.html index.htm; } location ~ .*.(php|php5)${
fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; fastcgi_cache ngx_fcgi_cache; fastcgi_cache_valid 200 302 1h; fastcgi_cache_valid 301 1d; fastcgi_cache_valid any 1m; fastcgi_cache_min_uses 1; fastcgi_cache_use_stale error timeout invalid_header http_500; fastcgi_cache_key http://$host$request_uri; } access_log logs/web_blog_access.log main; } upstream blog_etiantian{ server 10.0.0.8:8000 weight=1; } server { listen 8000; server_name blog.nmtui.com; location / { proxy_pass http://blog_etiantian; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; } access_log logs/proxy_blog_access.log main; } }

  <td style="width: 56.66%; border: solid #A5A5A5 1.0pt; mso-border-themecolor: accent3; border-left: none; mso-border-top-alt: solid #A5A5A5 .5pt; mso-border-top-themecolor: accent3; mso-border-bottom-alt: solid #A5A5A5 .5pt; mso-border-bottom-themecolor: accent3; mso-border-right-alt: solid #A5A5A5 .5pt; mso-border-right-themecolor: accent3; background: #A5A5A5; mso-background-themecolor: accent3; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: center; text-indent: 15.75pt; mso-yfti-cnfc: 1;" align="center">
      <strong><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; color: white; mso-themecolor: background1;">说明</span></strong>
    </p>
  </td>
</tr>

<tr style="mso-yfti-irow: 0;">
  <td style="width: 43.34%; border: solid #C9C9C9 1.0pt; mso-border-themecolor: accent3; mso-border-themetint: 153; border-top: none; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; background: #EDEDED; mso-background-themecolor: accent3; mso-background-themetint: 51; padding: 0cm 5.4pt 0cm 5.4pt;" width="43%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 68;">
      <strong><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">fastcgi_connect_timeout</span></strong>
    </p>
  </td>
  
  <td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #C9C9C9 1.0pt; mso-border-bottom-themecolor: accent3; mso-border-bottom-themetint: 153; border-right: solid #C9C9C9 1.0pt; mso-border-right-themecolor: accent3; mso-border-right-themetint: 153; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-left-alt: solid #C9C9C9 .5pt; mso-border-left-themecolor: accent3; mso-border-left-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; mso-border-themecolor: accent3; mso-border-themetint: 153; background: #EDEDED; mso-background-themecolor: accent3; mso-background-themetint: 51; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 64;">
      <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">表示</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">nginx</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">服务器和后端</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">FastCGI</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">服务器连接的超时时间,默认值为</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">60</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">秒,</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">这个参数值通常不要超过</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">75</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">秒,因为建立的连接越多,消耗的资源就越多</span>
    </p>
  </td>
</tr>

<tr style="mso-yfti-irow: 1;">
  <td style="width: 43.34%; border: solid #C9C9C9 1.0pt; mso-border-themecolor: accent3; mso-border-themetint: 153; border-top: none; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="43%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 4;">
      <strong><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">fastcgi_send_timeout</span></strong>
    </p>
  </td>
  
  <td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #C9C9C9 1.0pt; mso-border-bottom-themecolor: accent3; mso-border-bottom-themetint: 153; border-right: solid #C9C9C9 1.0pt; mso-border-right-themecolor: accent3; mso-border-right-themetint: 153; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-left-alt: solid #C9C9C9 .5pt; mso-border-left-themecolor: accent3; mso-border-left-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; mso-border-themecolor: accent3; mso-border-themetint: 153; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt;">
      <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">设置</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">nginx</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">传输请求到</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">FastCGI</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">服务器的超时时间,这个超时时间不是整个请</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">求的超时时间,而是两个成功请求的之间间隔时间为超时时间,如果这个时间</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">内,</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">FastCGI</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">服务没有收到任何信息,连接将关闭</span>
    </p>
  </td>
</tr>

<tr style="mso-yfti-irow: 2;">
  <td style="width: 43.34%; border: solid #C9C9C9 1.0pt; mso-border-themecolor: accent3; mso-border-themetint: 153; border-top: none; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; background: #EDEDED; mso-background-themecolor: accent3; mso-background-themetint: 51; padding: 0cm 5.4pt 0cm 5.4pt;" width="43%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 68;">
      <strong><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">fastcgi_read_timeout</span></strong>
    </p>
  </td>
  
  <td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #C9C9C9 1.0pt; mso-border-bottom-themecolor: accent3; mso-border-bottom-themetint: 153; border-right: solid #C9C9C9 1.0pt; mso-border-right-themecolor: accent3; mso-border-right-themetint: 153; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-left-alt: solid #C9C9C9 .5pt; mso-border-left-themecolor: accent3; mso-border-left-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; mso-border-themecolor: accent3; mso-border-themetint: 153; background: #EDEDED; mso-background-themecolor: accent3; mso-background-themetint: 51; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 64;">
      <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">设置</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">nginx</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">从</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">FastCGI</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">服务器读取响应信息的超时时间苯示连捿建立成功后,</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;"> nginx</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">等待后端服务器的响应时间,是</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">nginx</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">进入后端的排队之中的等候处理</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">的时间,实际上是读取</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">FastCGI</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">响应成功信息的间隔时间,</span>
    </p>
  </td>
</tr>

<tr style="mso-yfti-irow: 3;">
  <td style="width: 43.34%; border: solid #C9C9C9 1.0pt; mso-border-themecolor: accent3; mso-border-themetint: 153; border-top: none; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="43%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 4;">
      <strong><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">fastcgi_buffer_size</span></strong>
    </p>
  </td>
  
  <td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #C9C9C9 1.0pt; mso-border-bottom-themecolor: accent3; mso-border-bottom-themetint: 153; border-right: solid #C9C9C9 1.0pt; mso-border-right-themecolor: accent3; mso-border-right-themetint: 153; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-left-alt: solid #C9C9C9 .5pt; mso-border-left-themecolor: accent3; mso-border-left-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; mso-border-themecolor: accent3; mso-border-themetint: 153; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt;">
      <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">这是</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">Nginx FastCGI</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">的缓冲区大小参数,设定用来读取从</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">FastCGI</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">服务器端收</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">到的第一部分响应信息的缓冲区大小,这里的第一部分通常会包含一个小的响</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">应头部</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">s</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">默认情况下,这个参数的大小等价于</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">_</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">个内存页。不是</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">4k</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">就是</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">8k </span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">根据相应系统平台来决定,也可以更小。</span>
    </p>
  </td>
</tr>

<tr style="mso-yfti-irow: 4;">
  <td style="width: 43.34%; border: solid #C9C9C9 1.0pt; mso-border-themecolor: accent3; mso-border-themetint: 153; border-top: none; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; background: #EDEDED; mso-background-themecolor: accent3; mso-background-themetint: 51; padding: 0cm 5.4pt 0cm 5.4pt;" width="43%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 68;">
      <strong><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">fastcgi_buffers</span></strong>
    </p>
  </td>
  
  <td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #C9C9C9 1.0pt; mso-border-bottom-themecolor: accent3; mso-border-bottom-themetint: 153; border-right: solid #C9C9C9 1.0pt; mso-border-right-themecolor: accent3; mso-border-right-themetint: 153; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-left-alt: solid #C9C9C9 .5pt; mso-border-left-themecolor: accent3; mso-border-left-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; mso-border-themecolor: accent3; mso-border-themetint: 153; background: #EDEDED; mso-background-themecolor: accent3; mso-background-themetint: 51; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 64;">
      <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">设定用来读取从</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">FastCGI</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">服务器端收到的响应信息的缓冲区大小和缓冲区数</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">是,默认值为</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">fastcgi_buffer 8 4k|8k;</span>
    </p>
    
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 64;">
      <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">指定本地需要用多少和多大的缓冲区来缓冲</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">FastCGI</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">的应答请求,如果一个</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;"> PHP</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">脚本产生的页面大小为</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">256KB ,</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">那么会为其分配</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">4</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">个</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">64KB</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">的缓冲区来缓</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">存;如果页面大小大于</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">256KB ,</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">那么大于</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">256KB</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">的部分会缓存到</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">fastcgi_temp </span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">指定的路径中,但是这并不是好方法,因为内存中的数据处理速度要快于硬盘。</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">一般这个值应该为站点中</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">PHP</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">脚本产生的页面大小的中间值,如果站点大部分</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">脚本所产生的页面大小为</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">256KB ,</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">那么可以把这个值设置为</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">"16 16k" , "4 64k"</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">等</span>
    </p>
  </td>
</tr>

<tr style="mso-yfti-irow: 5;">
  <td style="width: 43.34%; border: solid #C9C9C9 1.0pt; mso-border-themecolor: accent3; mso-border-themetint: 153; border-top: none; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="43%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 4;">
      <strong><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">fastcgi_busy_buffers_size</span></strong>
    </p>
  </td>
  
  <td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #C9C9C9 1.0pt; mso-border-bottom-themecolor: accent3; mso-border-bottom-themetint: 153; border-right: solid #C9C9C9 1.0pt; mso-border-right-themecolor: accent3; mso-border-right-themetint: 153; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-left-alt: solid #C9C9C9 .5pt; mso-border-left-themecolor: accent3; mso-border-left-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; mso-border-themecolor: accent3; mso-border-themetint: 153; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt;">
      <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">用于设置系统很忙时可以使用的</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">fastcgi_buffers</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">大小,言方推荐的大小为</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">fastcgi_buffers*2 ;</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">默认值为</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;"> fastcgi_busy_buffers_size 8k|16k</span>
    </p>
  </td>
</tr>

<tr style="mso-yfti-irow: 6;">
  <td style="width: 43.34%; border: solid #C9C9C9 1.0pt; mso-border-themecolor: accent3; mso-border-themetint: 153; border-top: none; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; background: #EDEDED; mso-background-themecolor: accent3; mso-background-themetint: 51; padding: 0cm 5.4pt 0cm 5.4pt;" width="43%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 68;">
      <strong><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">fastcgi_temp_file_write_size</span></strong>
    </p>
  </td>
  
  <td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #C9C9C9 1.0pt; mso-border-bottom-themecolor: accent3; mso-border-bottom-themetint: 153; border-right: solid #C9C9C9 1.0pt; mso-border-right-themecolor: accent3; mso-border-right-themetint: 153; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-left-alt: solid #C9C9C9 .5pt; mso-border-left-themecolor: accent3; mso-border-left-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; mso-border-themecolor: accent3; mso-border-themetint: 153; background: #EDEDED; mso-background-themecolor: accent3; mso-background-themetint: 51; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 64;">
      <span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">FastCGI</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">临时文件的大小,可以设置为</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">128~256KB ; </span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">默认</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">fastcgi_temp_file_write_size 8k|16k;</span>
    </p>
  </td>
</tr>

<tr style="mso-yfti-irow: 7;">
  <td style="width: 43.34%; border: solid #C9C9C9 1.0pt; mso-border-themecolor: accent3; mso-border-themetint: 153; border-top: none; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="43%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 4;">
      <strong><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">fastcgi_cache oldboy_nginx</span></strong>
    </p>
  </td>
  
  <td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #C9C9C9 1.0pt; mso-border-bottom-themecolor: accent3; mso-border-bottom-themetint: 153; border-right: solid #C9C9C9 1.0pt; mso-border-right-themecolor: accent3; mso-border-right-themetint: 153; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-left-alt: solid #C9C9C9 .5pt; mso-border-left-themecolor: accent3; mso-border-left-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; mso-border-themecolor: accent3; mso-border-themetint: 153; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt;">
      <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">表示开后</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">FastCGI</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">缓存并为其指定一个名称。开后缓存非常有用,可以有效降</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">低</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">CPU</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">的负载,并且防止</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">502</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">错误的发生,但是开后缓存也可能引起其它问</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">题,要根据具体情况来选择</span>
    </p>
  </td>
</tr>

<tr style="mso-yfti-irow: 8;">
  <td style="width: 43.34%; border: solid #C9C9C9 1.0pt; mso-border-themecolor: accent3; mso-border-themetint: 153; border-top: none; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; background: #EDEDED; mso-background-themecolor: accent3; mso-background-themetint: 51; padding: 0cm 5.4pt 0cm 5.4pt;" width="43%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 68;">
      <strong><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">fastcgi_cache_path</span></strong>
    </p>
  </td>
  
  <td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #C9C9C9 1.0pt; mso-border-bottom-themecolor: accent3; mso-border-bottom-themetint: 153; border-right: solid #C9C9C9 1.0pt; mso-border-right-themecolor: accent3; mso-border-right-themetint: 153; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-left-alt: solid #C9C9C9 .5pt; mso-border-left-themecolor: accent3; mso-border-left-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; mso-border-themecolor: accent3; mso-border-themetint: 153; background: #EDEDED; mso-background-themecolor: accent3; mso-background-themetint: 51; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 64;">
      <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">实例:</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">fastcgi_cache_path /data/nginx/cache levels = 2:2 keys_zone = ngx_fcgi_cache:512m inactive = ld max_size=40g; fastcgi_cache</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">缓存目录,可以设置目录前列层级,比如</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">2:2</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">会生成</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">256*256 </span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">个子目录,</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">keys_zone</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">是这个缓存空间的名字,</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">cache</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">是用多少内存(这样热</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">门的内容,</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">nginx</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">会直接放入内存,提高访问速度)。</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">inactive</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">表示默认失效时</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">间,</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">max_size</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">表示最多用多少硬盘空间,雲要注意的是</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">fastcgi_cache</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">缓存是</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">先写在</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">fastcgi_temp_path</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">在移到</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">fastcgi_cache_path</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">中去的,所以这个两个</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">目录最好在同一个分区,从</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">0.8.9</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">之后可以在不同的分区,不过还是建议放在</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">同</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">_</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">分区。</span>
    </p>
  </td>
</tr>

<tr style="mso-yfti-irow: 9;">
  <td style="width: 43.34%; border: solid #C9C9C9 1.0pt; mso-border-themecolor: accent3; mso-border-themetint: 153; border-top: none; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="43%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 4;">
      <strong><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">fastcgi_cache_valid</span></strong>
    </p>
  </td>
  
  <td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #C9C9C9 1.0pt; mso-border-bottom-themecolor: accent3; mso-border-bottom-themetint: 153; border-right: solid #C9C9C9 1.0pt; mso-border-right-themecolor: accent3; mso-border-right-themetint: 153; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-left-alt: solid #C9C9C9 .5pt; mso-border-left-themecolor: accent3; mso-border-left-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; mso-border-themecolor: accent3; mso-border-themetint: 153; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt;">
      <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">示例:</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">fastcgi_cache_valid 200 302 lh;<span style="mso-spacerun: yes;">  </span></span>
    </p>
    
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt;">
      <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">用来指定应答代码的缓存时间,实例中的值表示将</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">200</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">和</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">302</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">应答缓存</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">1</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">个小</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">时;</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;"><span style="mso-spacerun: yes;">  </span></span>
    </p>
    
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt;">
      <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">示例:</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">fastcgi_cache_valid 301 Id;<span style="mso-spacerun: yes;">  </span></span>
    </p>
    
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt;">
      <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">将</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">301</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">应答缓存</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">1</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">天;</span>
    </p>
  </td>
</tr>

<tr style="mso-yfti-irow: 10;">
  <td style="width: 43.34%; border: solid #C9C9C9 1.0pt; mso-border-themecolor: accent3; mso-border-themetint: 153; border-top: none; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; background: #EDEDED; mso-background-themecolor: accent3; mso-background-themetint: 51; padding: 0cm 5.4pt 0cm 5.4pt;" width="43%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 68;">
      <strong><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">fastcgi_cache_min_uses</span></strong>
    </p>
  </td>
  
  <td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #C9C9C9 1.0pt; mso-border-bottom-themecolor: accent3; mso-border-bottom-themetint: 153; border-right: solid #C9C9C9 1.0pt; mso-border-right-themecolor: accent3; mso-border-right-themetint: 153; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-left-alt: solid #C9C9C9 .5pt; mso-border-left-themecolor: accent3; mso-border-left-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; mso-border-themecolor: accent3; mso-border-themetint: 153; background: #EDEDED; mso-background-themecolor: accent3; mso-background-themetint: 51; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 64;">
      <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">示例:</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">fastcgi_cache_min_uses 1;<span style="mso-spacerun: yes;">  </span></span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">设置清求几次之后晌应将被缓存,</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">1</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">表示一次即被缓存</span>
    </p>
  </td>
</tr>

<tr style="mso-yfti-irow: 11;">
  <td style="width: 43.34%; border: solid #C9C9C9 1.0pt; mso-border-themecolor: accent3; mso-border-themetint: 153; border-top: none; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="43%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 4;">
      <strong><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">fastcgi_cache_use_stale</span></strong>
    </p>
  </td>
  
  <td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #C9C9C9 1.0pt; mso-border-bottom-themecolor: accent3; mso-border-bottom-themetint: 153; border-right: solid #C9C9C9 1.0pt; mso-border-right-themecolor: accent3; mso-border-right-themetint: 153; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-left-alt: solid #C9C9C9 .5pt; mso-border-left-themecolor: accent3; mso-border-left-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; mso-border-themecolor: accent3; mso-border-themetint: 153; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt;">
      <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">示例:</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">fastcgi_cache_use_stale error timeout invalid_header http_500 </span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">定义在哪些情况下使用过期缓存</span>
    </p>
  </td>
</tr>

<tr style="mso-yfti-irow: 12; mso-yfti-lastrow: yes;">
  <td style="width: 43.34%; border: solid #C9C9C9 1.0pt; mso-border-themecolor: accent3; mso-border-themetint: 153; border-top: none; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; background: #EDEDED; mso-background-themecolor: accent3; mso-background-themetint: 51; padding: 0cm 5.4pt 0cm 5.4pt;" width="43%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 68;">
      <strong><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">fastcgi_cache_key</span></strong>
    </p>
  </td>
  
  <td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #C9C9C9 1.0pt; mso-border-bottom-themecolor: accent3; mso-border-bottom-themetint: 153; border-right: solid #C9C9C9 1.0pt; mso-border-right-themecolor: accent3; mso-border-right-themetint: 153; mso-border-top-alt: solid #C9C9C9 .5pt; mso-border-top-themecolor: accent3; mso-border-top-themetint: 153; mso-border-left-alt: solid #C9C9C9 .5pt; mso-border-left-themecolor: accent3; mso-border-left-themetint: 153; mso-border-alt: solid #C9C9C9 .5pt; mso-border-themecolor: accent3; mso-border-themetint: 153; background: #EDEDED; mso-background-themecolor: accent3; mso-background-themetint: 51; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 64;">
      <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">示例:</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">fastcgi_cache_key $request_method://$host$request_uri; fastcgi.cache.key http://$host$request_uri;</span>
    </p>
    
    <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 15.75pt; mso-yfti-cnfc: 64;">
      <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">定义</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">fastcgi_cache</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">的</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">key ,</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">示例中以请求的</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">URI</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">作为缓存的</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">key</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">,</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">nginx</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">会取</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">这个</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">key</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">的</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">md5</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">作为缓存文件,如果设置了缓存散列目录,</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">nginx</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">会从后往前取梠应的位数作为目录。</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">注意一定要加作为</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">cache key,</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">否则如果先请求的为</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">head </span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">类型,后面的</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;">GET</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">清求返回为空。</span>
    </p>
  </td>
</tr>
<span lang="EN-US" style="mso-fareast-font-family: 'Courier New'; mso-bidi-font-family: 'Courier New';"><span style="mso-list: Ignore;">1.4 </span></span><!--[endif]-->

<span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">日志方面优化</span></span>
<span lang="EN-US" style="mso-fareast-font-family: 'Courier New'; mso-bidi-font-family: 'Courier New';"><span style="mso-list: Ignore;">1.4.1 </span></span><!--[endif]-->

<span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">配置</span><span lang="EN-US">Nginx</span><span style="mso-bookmark: _Toc507528126;"><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">服务相关日志操作</span></span></span>

[root@clsn ~]# cd /server/scripts/ [root@clsn scripts]# vim cut_nginx_log.sh #!/bin/bash cd /application/nginx/logs &&
/bin/mv www_access.log www_access_$(date +%F -d -1day).log #<==将日志按日期改成前一天的名称 /application/nginx/sbin/nginx -s reload #<==重新加载nginx使得触发重新生成访问日志文件

access_log off; }

chmod -R 700 /app/logs

<span lang="EN-US" style="mso-fareast-font-family: 'Courier New'; mso-bidi-font-family: 'Courier New';"><span style="mso-list: Ignore;">1.4.2 </span></span><!--[endif]-->

<span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">查看软件编译时的参数</span></span>

/application/apache/bin/apachectl -V #<–也可查看安装时编译信息,但显示的不全

  <li>
    <a href="#13_Nginx">1.3 Nginx性能优化</a><ul>
      <li>
        <a href="#131_nginx_worker">1.3.1 优化nginx worker进行个数</a>
      </li>
      <li>
        <a href="#132_nginxCPU">1.3.2 绑定不同的nginx进程到不同的CPU上</a>
      </li>
      <li>
        <a href="#133_nginx">1.3.3 优化nginx事件处理模型</a>
      </li>
      <li>
        <a href="#134_nginx">1.3.4 调整nginx单个进程允许的客户端最大连接数</a>
      </li>
      <li>
        <a href="#135_Nginx_worker">1.3.5 配置Nginx worker进程最大打开文件数</a>
      </li>
      <li>
        <a href="#136_nginx">1.3.6 优化nginx高效文件传输模式</a>
      </li>
      <li>
        <a href="#137_nginx">1.3.7 设置nginx服务超时参数</a>
      </li>
      <li>
        <a href="#138_Nginx_gzip">1.3.8 配置Nginx gzip压缩实现性能优化</a>
      </li>
      <li>
        <a href="#139_Nginx_expires">1.3.9 配置Nginx expires缓存实现性能优化</a>
      </li>
      <li>
        <a href="#1310_FastCGI">1.3.10 配置FastCGI优化</a>
      </li>
    </ul>
  </li>
  
  <li>
    <a href="#14">1.4 日志方面优化</a><ul>
      <li>
        <a href="#141_Nginx">1.4.1 配置Nginx服务相关日志操作</a>
      </li>
      <li>
        <a href="#142">1.4.2 查看软件编译时的参数</a>
      </li>
    </ul>
  </li>
</ul>