<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>化繁成简... 破茧成蝶 &#187; Nginx</title>
	<atom:link href="http://www.800l.com/tag/nginx/feed" rel="self" type="application/rss+xml" />
	<link>http://www.800l.com</link>
	<description>From now on, i only care about the person who care about me.</description>
	<lastBuildDate>Mon, 06 Feb 2012 07:10:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>为nginx站点添加ipv6访问</title>
		<link>http://www.800l.com/nginx-host-add-ipv6.html</link>
		<comments>http://www.800l.com/nginx-host-add-ipv6.html#comments</comments>
		<pubDate>Sun, 07 Aug 2011 01:01:52 +0000</pubDate>
		<dc:creator>PRC</dc:creator>
				<category><![CDATA[技术相关]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nginx]]></category>

		<guid isPermaLink="false">http://www.800l.com/?p=813</guid>
		<description><![CDATA[最近为博客添加了ipv4、ipv6双解析，使用教育网进行v6测试通过，市区的网络是不支持ipv6的，其实添加ipv6非常简单，当然，首先，你必须为你的nginx安装好ipv6模块，就是在编译的时候使用&#8211;with-ipv6来安装，配置非常简单，我是配置ipv6独立ip访问，设置如下，在server段中，原先的设置完全不必变动，只需在listen 80下面加入下面一行即可，然后重启你的nginx。
listen    [2607:f358:1:fed5:22:0:????:????]:80 ipv6only=on;
]]></description>
			<content:encoded><![CDATA[<p>最近为博客添加了ipv4、ipv6双解析，使用教育网进行v6测试通过，市区的网络是不支持ipv6的，其实添加ipv6非常简单，当然，首先，你必须为你的nginx安装好ipv6模块，就是在编译的时候使用&#8211;with-ipv6来安装，配置非常简单，我是配置ipv6独立ip访问，设置如下，在server段中，原先的设置完全不必变动，只需在listen 80下面加入下面一行即可，然后重启你的nginx。</p>
<blockquote><p>listen    [2607:f358:1:fed5:22:0:????:????]:80 ipv6only=on;</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.800l.com/nginx-host-add-ipv6.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>为特定Nginx站点设置SSL</title>
		<link>http://www.800l.com/nginx-host-add-ssl.html</link>
		<comments>http://www.800l.com/nginx-host-add-ssl.html#comments</comments>
		<pubDate>Sun, 07 Aug 2011 00:52:13 +0000</pubDate>
		<dc:creator>PRC</dc:creator>
				<category><![CDATA[技术相关]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nginx]]></category>

		<guid isPermaLink="false">http://www.800l.com/?p=811</guid>
		<description><![CDATA[参考文献：http://wiki.nginx.org/NginxHttpSslModule
1.生成SSL证书公私钥
openssl req -new -x509 -nodes -out cert.pem -keyout cert.key
2.修改站点入站端口和加载SSL证书
server的监听由80改为443：listen 443;
在server中添加下面几行加载证书
        ssl                  on;
ssl_certificate      你的证书路径/cert.pem;
ssl_certificate_key   [...]]]></description>
			<content:encoded><![CDATA[<p>参考文献：<a href="http://wiki.nginx.org/NginxHttpSslModule" target="_blank">http://wiki.nginx.org/NginxHttpSslModule</a></p>
<p>1.生成SSL证书公私钥</p>
<p>openssl req -new -x509 -nodes -out cert.pem -keyout cert.key</p>
<p>2.修改站点入站端口和加载SSL证书</p>
<p>server的监听由80改为443：listen 443;</p>
<p>在server中添加下面几行加载证书<span id="more-811"></span></p>
<blockquote><p>        ssl                  on;<br />
ssl_certificate      你的证书路径/cert.pem;<br />
ssl_certificate_key  你的证书路径/cert.key;</p></blockquote>
<p>还有些参数请自行添加</p>
<p>3.重启Nginx</p>
<blockquote><p>/user/local/nginx/sbin/nginx -s reload</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.800l.com/nginx-host-add-ssl.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>为nginx添加http auth basic认证</title>
		<link>http://www.800l.com/nginx-http-auth-basic.html</link>
		<comments>http://www.800l.com/nginx-http-auth-basic.html#comments</comments>
		<pubDate>Sun, 07 Aug 2011 00:44:27 +0000</pubDate>
		<dc:creator>PRC</dc:creator>
				<category><![CDATA[技术相关]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Nginx]]></category>

		<guid isPermaLink="false">http://www.800l.com/?p=803</guid>
		<description><![CDATA[参考文献：http://wiki.nginx.org/NginxHttpAuthBasicModule
1.生成指定登录密钥
cd /usr/local/nginx/conf
mkdir auth
cd auth/
htpasswd -c -d .htpasswd 用户名   #回车并输入密码再回车
2.编conf配置
代码可以放在 http, server, location, limit_except  段
auth_basic   “Restricted”;
auth_basic_user_file    [...]]]></description>
			<content:encoded><![CDATA[<p>参考文献：http://wiki.nginx.org/NginxHttpAuthBasicModule</p>
<p>1.生成指定登录密钥</p>
<blockquote><p>cd /usr/local/nginx/conf<br />
mkdir auth<br />
cd auth/<br />
htpasswd -c -d .htpasswd 用户名   #回车并输入密码再回车</p></blockquote>
<p><span id="more-803"></span>2.编conf配置</p>
<p>代码可以放在 http, server, location, limit_except  段</p>
<blockquote><p>auth_basic   “Restricted”;<br />
auth_basic_user_file   auth/.htpasswd;</p></blockquote>
<p>3.重启nginx</p>
<blockquote><p>/usr/local/nginx/sbin/nginx -s reload</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.800l.com/nginx-http-auth-basic.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>cacti监控nginx出现 no (LWP::UserAgent not found)</title>
		<link>http://www.800l.com/cacti-nginx-no-lwpuseragent-not-found.html</link>
		<comments>http://www.800l.com/cacti-nginx-no-lwpuseragent-not-found.html#comments</comments>
		<pubDate>Fri, 27 May 2011 00:48:50 +0000</pubDate>
		<dc:creator>PRC</dc:creator>
				<category><![CDATA[技术相关]]></category>
		<category><![CDATA[Cacti]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Nginx]]></category>

		<guid isPermaLink="false">http://www.800l.com/?p=762</guid>
		<description><![CDATA[当你使用cacti监控nginx性能时可能会出现 no (LWP::UserAgent not found) 的错误。经过我两台VPS环境对比发现的确原因是系统 perl 缺少了相关组件，但是解决办法却不是网络上搜出来的那些
cpan&#62; install LWP::UserAgent
经过对比发现，缺少的是perl-libwww-perl这个软件包，解决方法就是直接yum安装进去就ok了。
yum -y install perl-libwww-perl
]]></description>
			<content:encoded><![CDATA[<p>当你使用cacti监控nginx性能时可能会出现 no (LWP::UserAgent not found) 的错误。经过我两台VPS环境对比发现的确原因是系统 perl 缺少了相关组件，但是解决办法却不是网络上搜出来的那些</p>
<blockquote><p><span style="color: #000000;"><del>cpan&gt; install LWP::UserAgent</del></span></p></blockquote>
<p>经过对比发现，缺少的是perl-libwww-perl这个软件包，解决方法就是直接yum安装进去就ok了。<span id="more-762"></span></p>
<blockquote><p>yum -y install perl-libwww-perl</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.800l.com/cacti-nginx-no-lwpuseragent-not-found.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nginx 充分利用多核CPU</title>
		<link>http://www.800l.com/nginx-mti-core-cpu-usge.html</link>
		<comments>http://www.800l.com/nginx-mti-core-cpu-usge.html#comments</comments>
		<pubDate>Sat, 02 Apr 2011 05:28:16 +0000</pubDate>
		<dc:creator>PRC</dc:creator>
				<category><![CDATA[技术相关]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nginx]]></category>

		<guid isPermaLink="false">http://www.800l.com/?p=705</guid>
		<description><![CDATA[参考官方文档：http://wiki.nginx.org/CoreModule
指令：worker_cpu_affinity
有多少核就有多少位，比如以下4核cpu每个进程一个核



worker_processes     4;
worker_cpu_affinity 0001 0010 0100 1000;

2核 cpu每个核2个进程，从末尾向上数每1位代表0，1，2，3核

worker_processes     4;
worker_cpu_affinity 01 10 01 10;



]]></description>
			<content:encoded><![CDATA[<p>参考官方文档：http://wiki.nginx.org/CoreModule</p>
<p>指令：worker_cpu_affinity</p>
<p>有多少核就有多少位，比如以下4核cpu每个进程一个核</p>
<div dir="ltr">
<div>
<blockquote>
<pre>worker_processes     4;
worker_cpu_affinity 0001 0010 0100 1000;</pre>
</blockquote>
<p><span id="more-705"></span>2核 cpu每个核2个进程，从末尾向上数每1位代表0，1，2，3核</p>
<blockquote>
<pre>worker_processes     4;
worker_cpu_affinity 01 10 01 10;</pre>
</blockquote>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.800l.com/nginx-mti-core-cpu-usge.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows 下的 Nginx 问题多多</title>
		<link>http://www.800l.com/nginx-windows-problems.html</link>
		<comments>http://www.800l.com/nginx-windows-problems.html#comments</comments>
		<pubDate>Sun, 27 Mar 2011 01:42:56 +0000</pubDate>
		<dc:creator>PRC</dc:creator>
				<category><![CDATA[技术相关]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.800l.com/?p=693</guid>
		<description><![CDATA[今天本来打算在Windows上上个nginx生产环境，配置改了半天不见生效，查了下文档，彻底无语了，Nginx在Windows下的Worker只有1个，并发还不能超过1024，不支持Vista及其后版本，详细请见官方文档，真悲剧，还是得用apache。
]]></description>
			<content:encoded><![CDATA[<p>今天本来打算在Windows上上个nginx生产环境，配置改了半天不见生效，查了下文档，彻底无语了，Nginx在Windows下的Worker只有1个，并发还不能超过1024，不支持Vista及其后版本，详细请见<a href="http://nginx.org/en/docs/windows.html" target="_blank">官方文档</a>，真悲剧，还是得用apache。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.800l.com/nginx-windows-problems.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nginx安装phpMyAdmin出现Http400错误解决方法</title>
		<link>http://www.800l.com/nginx-phpmyadmin-http400.html</link>
		<comments>http://www.800l.com/nginx-phpmyadmin-http400.html#comments</comments>
		<pubDate>Tue, 15 Feb 2011 11:52:15 +0000</pubDate>
		<dc:creator>PRC</dc:creator>
				<category><![CDATA[技术相关]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[phpMyAdmin]]></category>

		<guid isPermaLink="false">http://www.800l.com/?p=559</guid>
		<description><![CDATA[HTTP 400
The plain HTTP request was sent to HTTPS port
能看到这篇文章说明你正尝试用ssl访问phpmyadmin,google一下早有牛人在07年就解决了这个问题：
在

fastcgi_pass  127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
fastcgi_param HTTPS on;（加到这里，上下无所谓在大括号内即可）
加入
fastcgi_param HTTPS     on;
平滑重启即可。
]]></description>
			<content:encoded><![CDATA[<blockquote><p>HTTP 400</p>
<p>The plain HTTP request was sent to HTTPS port</p></blockquote>
<p>能看到这篇文章说明你正尝试用ssl访问phpmyadmin,google一下早有牛人在07年就解决了这个问题：</p>
<p>在</p>
<p><span id="more-559"></span></p>
<blockquote><p>fastcgi_pass  127.0.0.1:9000;<br />
fastcgi_index index.php;<br />
include fcgi.conf;<br />
<span style="color: #ff0000;">fastcgi_param HTTPS on;（加到这里，上下无所谓在大括号内即可）</span></p></blockquote>
<p>加入</p>
<blockquote><p><code><code><code>fastcgi_param HTTPS     on;</code></code></code></p></blockquote>
<p>平滑重启即可。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.800l.com/nginx-phpmyadmin-http400.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>有关 Nginx + PHP + MySQL 的搭建</title>
		<link>http://www.800l.com/nginx-php-mysql.html</link>
		<comments>http://www.800l.com/nginx-php-mysql.html#comments</comments>
		<pubDate>Mon, 14 Feb 2011 02:11:33 +0000</pubDate>
		<dc:creator>PRC</dc:creator>
				<category><![CDATA[技术相关]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.800l.com/?p=554</guid>
		<description><![CDATA[关于这个教程的话，我看最权威的就是张宴大师的博客了，不转载
只给出链接http://blog.s135.com/nginx_php_v6/
]]></description>
			<content:encoded><![CDATA[<p>关于这个教程的话，我看最权威的就是张宴大师的博客了，不转载</p>
<p><span id="more-554"></span>只给出链接http://blog.s135.com/nginx_php_v6/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.800l.com/nginx-php-mysql.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>yum 安装 Nginx</title>
		<link>http://www.800l.com/yum-nginx.html</link>
		<comments>http://www.800l.com/yum-nginx.html#comments</comments>
		<pubDate>Fri, 11 Feb 2011 05:00:49 +0000</pubDate>
		<dc:creator>PRC</dc:creator>
				<category><![CDATA[技术相关]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[epel]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nginx]]></category>

		<guid isPermaLink="false">http://www.800l.com/?p=537</guid>
		<description><![CDATA[系统自带源不含nginx。可以利用 epel(xtra Packages for Enterprise Linux) 这个开源的yum源，这个是针对RHEL设计的，由Fedora组织维护，可以用于CentOS、RHEL。
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
yum -y install nginx
chkconfig nginx on
安装好后是稳定版的放心。
]]></description>
			<content:encoded><![CDATA[<p>系统自带源不含nginx。可以利用 <strong>epel</strong>(xtra Packages for Enterprise Linux) 这个开源的yum源，这个是针对RHEL设计的，由Fedora组织维护，可以用于CentOS、RHEL。</p>
<blockquote><p>rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm<br />
yum -y install nginx<br />
chkconfig nginx on</p></blockquote>
<p>安装好后是稳定版的放心。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.800l.com/yum-nginx.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux下Nginx+Tomcat整合的安装与配置</title>
		<link>http://www.800l.com/linux-nginx-tomcat-jdk.html</link>
		<comments>http://www.800l.com/linux-nginx-tomcat-jdk.html#comments</comments>
		<pubDate>Sun, 02 May 2010 14:22:00 +0000</pubDate>
		<dc:creator>PRC</dc:creator>
				<category><![CDATA[技术相关]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nginx]]></category>

		<guid isPermaLink="false">http://www.800l.com/?p=493</guid>
		<description><![CDATA[一、安装Tomcat和JDK
1、上传apache-tomcat-6.0.18.tar.gz和jdk-6u12-linux-i586.bin至/usr/local
2、执行如下命令安装tomcat：



#cd /usr/local 
#tar zxvf  [...]]]></description>
			<content:encoded><![CDATA[<p><strong>一、安装Tomcat和JDK</strong></p>
<p>1、上传apache-tomcat-6.0.18.tar.gz和jdk-6u12-linux-i586.bin至/usr/local<br />
2、执行如下命令安装tomcat：</p>
<div id="highlighter_392234">
<div>
<blockquote>
<div><code>#cd /usr/local </code></div>
<div><code>#tar zxvf apache-tomcat-</code><code>6.0</code><code>.</code><code>18</code><code>.tar.gz</code></div>
</blockquote>
</div>
</div>
<p> <span id="more-493"></span></p>
<p>解压完成后将apache-tomcat-6.0.18重命名为tomcat<br />
3、执行如下命令安装JDK:</p>
<div id="highlighter_430585">
<div>
<blockquote>
<div><code>#./jdk-6u12-linux-i586.bin</code></div>
<div> </div>
</blockquote>
</div>
</div>
<p>4、配置环境变量：<br />
编辑/etc下的profile文件，加上如下内容：<code> </code> </p>
<div id="highlighter_62590">
<div>
<blockquote>
<div><code>JAVA_HOME=</code><code>"/usr/local/jdk1.6.0_12"</code></div>
<div><code>CLASS_PATH=</code><code>"$JAVA_HOME/lib:$JAVA_HOME/jre/lib"</code></div>
<div><code>PATH=</code><code>".:$PATH:$JAVA_HOME/bin "</code></div>
<div><code> </code> </div>
<div><code>CATALINA_HOME=</code><code>"/usr/local/tomcat"</code></div>
<div><code>export JAVA_HOME CATALINA_HOME</code></div>
</blockquote>
</div>
</div>
<p>5、启动tomcat并输入http://localhost:8080，如果看到猫的页面即tomcat和jdk安装成功<br />
6、新建文件目录/home/www为网站存放目录，设置server.xml文件，在Host name=”localhost”处将appBase=的指向路径改为/home/www/web<br />
7、创建index.jsp至/home/www/web/ROOT，内容为：“My web!”  </p>
<p> </p>
<p><strong>二、安装Nginx<br />
</strong>1、上传nginx-0.7.63.tar.gz至/usr/local</p>
<p>2、执行如下命令解压nginx：</p>
<div id="highlighter_472038">
<div>
<blockquote>
<div><code>#cd /usr/local </code></div>
<div><code>#tar zxvf  nginx-</code><code>0.7</code><code>.</code><code>63</code><code>.tar.gz</code></div>
</blockquote>
</div>
</div>
<p>3、编译安装nginx</p>
<div id="highlighter_680713">
<div>
<blockquote>
<div><code>#cd nginx-</code><code>0.7</code><code>.</code><code>63</code></div>
<div><code>#./configure --with-http_stub_status_module --with-http_ssl_module  #启动server状态页和https模块</code></div>
</blockquote>
</div>
</div>
<p>执行完后会提示一个错误，说缺少PCRE library 这个是HTTP Rewrite 模块，也即是url静态化的包<br />
可上传pcre-7.9.tar.gz，输入如下命令安装：</p>
<div id="highlighter_721461">
<div>
<blockquote>
<div><code>#tar zxvf pcre-</code><code>7.9</code><code>.tar.gz </code></div>
<div><code>#cd pcre-</code><code>7.9</code></div>
<div><code>#./configure </code></div>
<div><code>#make </code></div>
<div><code>#make install</code></div>
</blockquote>
</div>
</div>
<p>安装pcre成功后，继续安装nginx</p>
<div id="highlighter_623040">
<div>
<blockquote>
<div><code>#cd nginx-</code><code>0.7</code><code>.</code><code>63</code></div>
<div><code>#./configure </code></div>
<div><code>#make </code></div>
<div><code>#make install</code></div>
</blockquote>
</div>
</div>
<p>4、nginx安装成功后的安装目录为/usr/local/nginx<br />
在conf文件夹中新建proxy.conf，用于配置一些代理参数，内容如下：</p>
<div id="highlighter_483711">
<div>
<blockquote>
<div><code>#!nginx (-)  </code></div>
<div><code># proxy.conf  </code></div>
<div><code>proxy_redirect          off; </code></div>
<div><code>proxy_set_header        Host $host; </code></div>
<div><code>proxy_set_header        X-Real-IP $remote_addr;  #获取真实ip </code></div>
<div><code>#proxy_set_header       X-Forwarded-For   $proxy_add_x_forwarded_for; #获取代理者的真实ip </code></div>
<div><code>client_max_body_size    10m; </code></div>
<div><code>client_body_buffer_size 128k; </code></div>
<div><code>proxy_connect_timeout   </code><code>90</code><code>; </code></div>
<div><code>proxy_send_timeout      </code><code>90</code><code>; </code></div>
<div><code>proxy_read_timeout      </code><code>90</code><code>; </code></div>
<div><code>proxy_buffer_size       4k; </code></div>
<div><code>proxy_buffers           </code><code>4</code> <code>32k; </code></div>
<div><code>proxy_busy_buffers_size 64k; </code></div>
<div><code>proxy_temp_file_write_size 64k;</code></div>
<div> </div>
</blockquote>
</div>
</div>
<p>编辑安装目录下conf文件夹中的nginx.conf，输入如下内容<code> </code> </p>
<div id="highlighter_71789">
<div>
<blockquote>
<div><code>#运行nginx所在的用户名和用户组 </code></div>
<div><code>#user  www www;  </code></div>
<div><code> </code> </div>
<div><code>#启动进程数 </code></div>
<div><code>worker_processes </code><code>8</code><code>; </code></div>
<div><code>#全局错误日志及PID文件 </code></div>
<div><code>error_log  /usr/local/nginx/logs/nginx_error.log  crit; </code></div>
<div><code> </code> </div>
<div><code>pid        /usr/local/nginx/nginx.pid; </code></div>
<div><code> </code> </div>
<div><code>#Specifies the value </code><code>for</code> <code>maximum file descriptors that can be opened by </code><code>this</code> <code>process. </code></div>
<div><code> </code> </div>
<div><code>worker_rlimit_nofile </code><code>65535</code><code>; </code></div>
<div><code>#工作模式及连接数上限 </code></div>
<div><code>events </code></div>
<div><code>{ </code></div>
<div><code>  </code><code>use epoll; </code></div>
<div><code>  </code><code>worker_connections </code><code>65535</code><code>; </code></div>
<div><code>} </code></div>
<div><code>#设定http服务器，利用它的反向代理功能提供负载均衡支持 </code></div>
<div><code>http </code></div>
<div><code>{ </code></div>
<div><code>  </code><code>#设定mime类型 </code></div>
<div><code>  </code><code>include       mime.types; </code></div>
<div><code>  </code><code>default_type  application/octet-stream; </code></div>
<div><code>  </code><code>include /usr/local/nginx/conf/proxy.conf; </code></div>
<div><code>  </code><code>#charset  gb2312; </code></div>
<div><code>  </code><code>#设定请求缓冲     </code></div>
<div><code>  </code><code>server_names_hash_bucket_size </code><code>128</code><code>; </code></div>
<div><code>  </code><code>client_header_buffer_size 32k; </code></div>
<div><code>  </code><code>large_client_header_buffers </code><code>4</code> <code>32k; </code></div>
<div><code>  </code><code>client_max_body_size 8m; </code></div>
<div><code>       </code> </div>
<div><code>  </code><code>sendfile on; </code></div>
<div><code>  </code><code>tcp_nopush     on; </code></div>
<div><code> </code> </div>
<div><code>  </code><code>keepalive_timeout </code><code>60</code><code>; </code></div>
<div><code> </code> </div>
<div><code>  </code><code>tcp_nodelay on; </code></div>
<div><code> </code> </div>
<div><code>#  fastcgi_connect_timeout </code><code>300</code><code>; </code></div>
<div><code>#  fastcgi_send_timeout </code><code>300</code><code>; </code></div>
<div><code>#  fastcgi_read_timeout </code><code>300</code><code>; </code></div>
<div><code>#  fastcgi_buffer_size 64k; </code></div>
<div><code>#  fastcgi_buffers </code><code>4</code> <code>64k; </code></div>
<div><code>#  fastcgi_busy_buffers_size 128k; </code></div>
<div><code>#  fastcgi_temp_file_write_size 128k; </code></div>
<div><code> </code> </div>
<div><code>#  gzip on; </code></div>
<div><code>#  gzip_min_length  1k; </code></div>
<div><code>#  gzip_buffers     </code><code>4</code> <code>16k; </code></div>
<div><code>#  gzip_http_version </code><code>1.0</code><code>; </code></div>
<div><code>#  gzip_comp_level </code><code>2</code><code>; </code></div>
<div><code>#  gzip_types       text/plain application/x-javascript text/css application/xml; </code></div>
<div><code>#  gzip_vary on; </code></div>
<div><code> </code> </div>
<div><code>  </code><code>#limit_zone  crawler  $binary_remote_addr  10m; </code></div>
<div><code> </code><code>###禁止通过ip访问站点 </code></div>
<div><code>  </code><code>server{ </code></div>
<div><code>        </code><code>server_name _; </code></div>
<div><code>        </code><code>return</code> <code>404</code><code>; </code></div>
<div><code>        </code><code>} </code></div>
<div><code> </code> </div>
<div><code> </code> </div>
<div><code>  </code><code>server </code></div>
<div><code>  </code><code>{ </code></div>
<div><code>    </code><code>listen       </code><code>80</code><code>; </code></div>
<div><code>    </code><code>server_name  localhost; </code></div>
<div><code>    </code><code>index index.html index.htm index.jsp;#设定访问的默认首页地址 </code></div>
<div><code>    </code><code>root  /home/www/web/ROOT;#设定网站的资源存放路径 </code></div>
<div><code> </code> </div>
<div><code>    </code><code>#limit_conn   crawler  </code><code>20</code><code>;     </code></div>
<div><code>     </code> </div>
<div><code>    </code><code>location ~ .*.jsp$ #所有jsp的页面均交由tomcat处理 </code></div>
<div><code>    </code><code>{ </code></div>
<div><code>      </code><code>index index.jsp; </code></div>
<div><code>      </code><code>proxy_pass http:</code><code>//localhost:8080;#转向tomcat处理 </code></div>
<div><code>      </code><code>} </code></div>
<div><code>       </code> </div>
<div><code>     </code> </div>
<div><code>    </code><code>location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ #设定访问静态文件直接读取不经过tomcat </code></div>
<div><code>    </code><code>{ </code></div>
<div><code>      </code><code>expires      30d; </code></div>
<div><code>    </code><code>} </code></div>
<div><code> </code> </div>
<div><code>    </code><code>location ~ .*\.(js|css)?$ </code></div>
<div><code>    </code><code>{ </code></div>
<div><code>      </code><code>expires      1h; </code></div>
<div><code>    </code><code>}     </code></div>
<div><code> </code> </div>
<div><code>#定义访问日志的写入格式 </code></div>
<div><code>     </code><code>log_format  access  </code><code>'$remote_addr - $remote_user [$time_local] "$request" '</code></div>
<div><code>              </code><code>'$status $body_bytes_sent "$http_referer" '</code></div>
<div><code>              </code><code>'"$http_user_agent" $http_x_forwarded_for'</code><code>; </code></div>
<div><code>    </code><code>access_log  /usr/local/nginx/logs/localhost.log access;#设定访问日志的存放路径 </code></div>
<div><code> </code> </div>
<div><code>      </code><code>} </code><code> </code> </div>
<div><code>} </code></div>
</blockquote>
</div>
</div>
<p>5、修改/usr/local/nginx/conf/nginx.conf配置文件后，请执行以下命令检查配置文件是否正确：</p>
<div id="highlighter_203603">
<div>
<blockquote>
<div><code>#/usr/local/nginx/sbin/nginx -t</code></div>
</blockquote>
</div>
</div>
<p>如果屏幕显示以下两行信息，说明配置文件正确：<code> </code> </p>
<div id="highlighter_275954">
<div>
<blockquote>
<div><code>the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok </code></div>
<div><code>　　the configuration file /usr/local/nginx/conf/nginx.conf was tested successfully</code></div>
</blockquote>
</div>
</div>
<p>如果提示unknown host，则可在服务器上执行：ping www.baidu.com如果也是同样提示unknown host则有两种可能：<br />
    a、服务器没有设置DNS服务器地址，查看/etc/resolv.conf下是否设置，若无则加上<br />
    b、防火墙拦截</p>
<p> 6、启动nginx的命令</p>
<div id="highlighter_253995">
<div>
<blockquote>
<div><code>#/usr/local/nginx/sbin/nginx</code></div>
</blockquote>
</div>
</div>
<p>这时，输入以下命令查看Nginx主进程号：</p>
<div id="highlighter_423482">
<div>
<blockquote>
<div><code>ps -ef | grep </code><code>"nginx: master process"</code> <code>| grep -v </code><code>"grep"</code> <code>| awk -F </code><code>' '</code> <code>'{print $2}'</code></div>
</blockquote>
</div>
</div>
<p>7、停止nginx的命令</p>
<div id="highlighter_539038">
<div>
<blockquote>
<div><code>#/usr/local/nginx/sbin/nginx -s stop</code></div>
</blockquote>
</div>
</div>
<p>8、在不停止Nginx服务的情况下平滑变更Nginx配置<br />
a、修改/usr/local/nginx/conf/nginx.conf配置文件后，请执行以下命令检查配置文件是否正确：</p>
<div id="highlighter_534160">
<div>
<blockquote>
<div><code>/usr/local/nginx/sbin/nginx -t</code></div>
</blockquote>
</div>
</div>
<p>　　如果屏幕显示以下两行信息，说明配置文件正确：</p>
<div id="highlighter_610157">
<div>
<blockquote>
<div><code>　　the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok </code></div>
<div><code>　　the configuration file /usr/local/nginx/conf/nginx.conf was tested successfully</code></div>
</blockquote>
</div>
</div>
<p>b、这时，输入以下命令查看Nginx主进程号：</p>
<div id="highlighter_859351">
<div>
<blockquote>
<div><code>ps -ef | grep </code><code>"nginx: master process"</code> <code>| grep -v </code><code>"grep"</code> <code>| awk -F </code><code>' '</code> <code>'{print $2}'</code></div>
</blockquote>
</div>
</div>
<p>屏幕显示的即为Nginx主进程号，例如：<br />
　　6302<br />
　　这时，执行以下命令即可使修改过的Nginx配置文件生效：</p>
<div id="highlighter_397280">
<div>
<blockquote>
<div><code>kill -HUP </code><code>6302</code></div>
</blockquote>
</div>
</div>
<p>　　<br />
或者无需这么麻烦，找到Nginx的Pid文件：</p>
<div id="highlighter_525329">
<div>
<blockquote>
<div><code>kill -HUP `cat /usr/local/nginx/nginx.pid`</code></div>
</blockquote>
</div>
</div>
<p>9、nginx启动好后启动tomcat，此时输入http://主机ip地址即可看到“My web!” </p>
<p> <br />
<strong>三、其他</strong><br />
stub_status<br />
语法: stub_status on</p>
<p>默认值: None</p>
<p>作用域: location</p>
<p>创建一个 location 区域启用 stub_status</p>
<p>“stub status” 模块返回的状态信息跟 mathopd&#8217;s 的状态信息很相似. 返回的状态信息如下：</p>
<div id="highlighter_463274">
<div>
<blockquote>
<div><code>Active connections: </code><code>291</code></div>
<div><code>server accepts handled requests </code></div>
<div><code>16630948</code> <code>16630948</code> <code>31070465</code></div>
<div><code>Reading: </code><code>6</code> <code>Writing: </code><code>179</code> <code>Waiting: </code><code>106</code></div>
</blockquote>
</div>
</div>
<p>active connections &#8212; 对后端发起的活动连接数</p>
<p>server accepts handled requests &#8212; nginx 总共处理了 16630948 个连接, 成功创建 16630948 次握手 (证明中间没有失败的), 总共处理了 31070465 个请求 (平均每次握手处理了 1.8个数据请求)</p>
<p>reading &#8212; nginx 读取到客户端的Header信息数</p>
<p>writing &#8212; nginx 返回给客户端的Header信息数</p>
<p>waiting &#8212; 开启 keep-alive 的情况下，这个值等于 active &#8211; (reading + writing)，意思就是Nginx说已经处理完正在等候下一次请求指令的驻留连接</p>
]]></content:encoded>
			<wfw:commentRss>http://www.800l.com/linux-nginx-tomcat-jdk.html/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

