<?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>gjw_apparitor 博客 &#187; Web</title>
	<atom:link href="http://www.apparitor.info/category/service/web/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.apparitor.info</link>
	<description>孤独是一种态度</description>
	<lastBuildDate>Wed, 16 May 2012 07:36:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>nginx指定某个文件不能缓存</title>
		<link>http://www.apparitor.info/2011/07/11/nginx%e6%8c%87%e5%ae%9a%e6%9f%90%e4%b8%aa%e6%96%87%e4%bb%b6%e4%b8%8d%e8%83%bd%e7%bc%93%e5%ad%98/</link>
		<comments>http://www.apparitor.info/2011/07/11/nginx%e6%8c%87%e5%ae%9a%e6%9f%90%e4%b8%aa%e6%96%87%e4%bb%b6%e4%b8%8d%e8%83%bd%e7%bc%93%e5%ad%98/#comments</comments>
		<pubDate>Mon, 11 Jul 2011 05:12:49 +0000</pubDate>
		<dc:creator>gjw_apparitor</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://www.apparitor.info/?p=367</guid>
		<description><![CDATA[nginx配置了所有图片都缓存，想让某个图盘不被缓存用于监控使用。 一开始指定 expires 为“0“和“-1“都不好用，反回的是403不是200. 添加一个header头为no cache还是不好用，用chrome浏览器还是会显示403。 最后把no cache改为 no-store后正常。 配置为： location ~* nocache\.jpg$ { add_header Cache-Control no-store; } 原创文章，转载请注明： 转载自gjw_apparitor 博客 本文链接地址: nginx指定某个文件不能缓存]]></description>
			<content:encoded><![CDATA[<p>nginx配置了所有图片都缓存，想让某个图盘不被缓存用于监控使用。</p>
<p>一开始指定 expires 为“0“和“-1“都不好用，反回的是403不是200.<br />
添加一个header头为no cache还是不好用，用chrome浏览器还是会显示403。<br />
最后把no cache改为 no-store后正常。<br />
配置为：<br />
                location ~* nocache\.jpg$ {<br />
			add_header Cache-Control no-store;<br />
                }
<div style="margin-top: 15px; font-style: italic">
<p><strong>原创文章，转载请注明：</strong> 转载自<a href="http://www.apparitor.info/">gjw_apparitor 博客</a></p>
<p><strong>本文链接地址:</strong> <a href="http://www.apparitor.info/2011/07/11/nginx%e6%8c%87%e5%ae%9a%e6%9f%90%e4%b8%aa%e6%96%87%e4%bb%b6%e4%b8%8d%e8%83%bd%e7%bc%93%e5%ad%98/">nginx指定某个文件不能缓存</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.apparitor.info/2011/07/11/nginx%e6%8c%87%e5%ae%9a%e6%9f%90%e4%b8%aa%e6%96%87%e4%bb%b6%e4%b8%8d%e8%83%bd%e7%bc%93%e5%ad%98/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>非常好的页面速度分析工具 Page Speed</title>
		<link>http://www.apparitor.info/2011/05/17/%e9%9d%9e%e5%b8%b8%e5%a5%bd%e7%9a%84%e9%a1%b5%e9%9d%a2%e9%80%9f%e5%ba%a6%e5%88%86%e6%9e%90%e5%b7%a5%e5%85%b7-page-speed/</link>
		<comments>http://www.apparitor.info/2011/05/17/%e9%9d%9e%e5%b8%b8%e5%a5%bd%e7%9a%84%e9%a1%b5%e9%9d%a2%e9%80%9f%e5%ba%a6%e5%88%86%e6%9e%90%e5%b7%a5%e5%85%b7-page-speed/#comments</comments>
		<pubDate>Tue, 17 May 2011 08:21:55 +0000</pubDate>
		<dc:creator>gjw_apparitor</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[Page Speed]]></category>

		<guid isPermaLink="false">http://www.apparitor.info/?p=353</guid>
		<description><![CDATA[Page Speed 是 Google Chrome 用来网页速度测试工具 ，不过由于使用了实验性的API，所以该扩展只在Google Code提供下载测试。 URL：http://code.google.com/intl/zh-CN/speed/page-speed/docs/using_chrome.html 按照上边的步骤去安装 Page Speed 最后测试了一下公司的主页 Page Speed Score: 68/100 叫我情何以堪！ 原创文章，转载请注明： 转载自gjw_apparitor 博客 本文链接地址: 非常好的页面速度分析工具 Page Speed]]></description>
			<content:encoded><![CDATA[<p>Page Speed 是 Google Chrome 用来网页速度测试工具 ，不过由于使用了实验性的API，所以该扩展只在Google Code提供下载测试。</p>
<p>URL：http://code.google.com/intl/zh-CN/speed/page-speed/docs/using_chrome.html</p>
<p>按照上边的步骤去安装 Page Speed</p>
<p>最后测试了一下公司的主页 </p>
<p>Page Speed Score: 68/100</p>
<p>叫我情何以堪！
<div style="margin-top: 15px; font-style: italic">
<p><strong>原创文章，转载请注明：</strong> 转载自<a href="http://www.apparitor.info/">gjw_apparitor 博客</a></p>
<p><strong>本文链接地址:</strong> <a href="http://www.apparitor.info/2011/05/17/%e9%9d%9e%e5%b8%b8%e5%a5%bd%e7%9a%84%e9%a1%b5%e9%9d%a2%e9%80%9f%e5%ba%a6%e5%88%86%e6%9e%90%e5%b7%a5%e5%85%b7-page-speed/">非常好的页面速度分析工具 Page Speed</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.apparitor.info/2011/05/17/%e9%9d%9e%e5%b8%b8%e5%a5%bd%e7%9a%84%e9%a1%b5%e9%9d%a2%e9%80%9f%e5%ba%a6%e5%88%86%e6%9e%90%e5%b7%a5%e5%85%b7-page-speed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>apache 配置SSI</title>
		<link>http://www.apparitor.info/2011/04/06/apache-%e9%85%8d%e7%bd%aessi/</link>
		<comments>http://www.apparitor.info/2011/04/06/apache-%e9%85%8d%e7%bd%aessi/#comments</comments>
		<pubDate>Wed, 06 Apr 2011 06:48:26 +0000</pubDate>
		<dc:creator>gjw_apparitor</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[apache]]></category>

		<guid isPermaLink="false">http://www.apparitor.info/?p=227</guid>
		<description><![CDATA[在apache的 httpd.conf中 去消掉前边的注释 AddType text/html .shtml AddOutputFilter INCLUDES .shtml AddHandler server-parsed .shtml .html Options Indexes FollowSymLinks Includes AllowOverride None Order allow,deny Allow from all 在Directory里添加 Options Indexes FollowSymLinks Includes 原创文章，转载请注明： 转载自gjw_apparitor 博客 本文链接地址: apache 配置SSI]]></description>
			<content:encoded><![CDATA[<p>在apache的 httpd.conf中</p>
<p>去消掉前边的注释<br />
AddType text/html .shtml<br />
AddOutputFilter INCLUDES .shtml<br />
AddHandler server-parsed .shtml .html</p>
<p><Directory "/"><br />
Options Indexes FollowSymLinks Includes<br />
AllowOverride None<br />
Order allow,deny<br />
Allow from all<br />
</Directory></p>
<p>在Directory里添加     Options Indexes FollowSymLinks Includes
<div style="margin-top: 15px; font-style: italic">
<p><strong>原创文章，转载请注明：</strong> 转载自<a href="http://www.apparitor.info/">gjw_apparitor 博客</a></p>
<p><strong>本文链接地址:</strong> <a href="http://www.apparitor.info/2011/04/06/apache-%e9%85%8d%e7%bd%aessi/">apache 配置SSI</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.apparitor.info/2011/04/06/apache-%e9%85%8d%e7%bd%aessi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nginx + pcre + zlib</title>
		<link>http://www.apparitor.info/2011/04/06/nginx-pcre-zlib/</link>
		<comments>http://www.apparitor.info/2011/04/06/nginx-pcre-zlib/#comments</comments>
		<pubDate>Wed, 06 Apr 2011 06:46:51 +0000</pubDate>
		<dc:creator>gjw_apparitor</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://www.apparitor.info/?p=225</guid>
		<description><![CDATA[prce http://www.pcre.org/ # wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.9.tar.gz # tar zxvf pcre-7.9.tar.gz # cd pcre-7.9 # ./configure # make &#038;&#038; make install zlib http://www.zlib.net/ # wget http://www.gzip.org/zlib/zlib-1.2.3.tar.gz # tar zxvf zlib-1.2.3.tar.gz # cd zlib-1.2.3 # ./configure # make &#038;&#038; make install # mkdir /usr/include/pcre/ # cp /usr/local/lib/libpcre.a /usr/include/pcre/libpcre.a # cp /usr/local/lib/libpcre.a /usr/include/pcre/libpcre.la # cp /root/pcre-7.9/pcre.h /usr/include/pcre/pcre.h # mkdir]]></description>
			<content:encoded><![CDATA[<p>prce</p>
<p>http://www.pcre.org/</p>
<pre># wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.9.tar.gz
# tar zxvf pcre-7.9.tar.gz
# cd pcre-7.9
# ./configure
# make &#038;&#038; make install</pre>
<p>zlib</p>
<p>http://www.zlib.net/</p>
<pre># wget http://www.gzip.org/zlib/zlib-1.2.3.tar.gz
# tar zxvf zlib-1.2.3.tar.gz
# cd zlib-1.2.3
# ./configure
# make &#038;&#038; make install
# mkdir /usr/include/pcre/
# cp /usr/local/lib/libpcre.a /usr/include/pcre/libpcre.a
# cp /usr/local/lib/libpcre.a /usr/include/pcre/libpcre.la
# cp /root/pcre-7.9/pcre.h /usr/include/pcre/pcre.h
# mkdir /usr/include/pcre/.libs
# cp /usr/local/lib/libpcre.a /usr/include/pcre/.libs/libpcre.a
# cp /usr/local/lib/libpcre.a /usr/include/pcre/.libs/libpcre.la
# cp /root/pcre-7.9/pcre.h /usr/include/pcre/.libs/pcre.h</pre>
<p>Nginx</p>
<p>http://nginx.net/</p>
<pre># http://sysoev.ru/nginx/nginx-0.7.62.tar.gz
# tar zxvf nginx-0.7.62.tar.gz
# cd /nginx-0.7.62
#./configure --prefix=/data_web/nginx-0.7.62/ \
--with-http_stub_status_module \
--with-http_gzip_static_module
vi objs/Makefile 删除“./configure –disable-shared”行
# make &#038;&#038; make install</pre>
<div style="margin-top: 15px; font-style: italic">
<p><strong>原创文章，转载请注明：</strong> 转载自<a href="http://www.apparitor.info/">gjw_apparitor 博客</a></p>
<p><strong>本文链接地址:</strong> <a href="http://www.apparitor.info/2011/04/06/nginx-pcre-zlib/">Nginx + pcre + zlib</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.apparitor.info/2011/04/06/nginx-pcre-zlib/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>apache worker模式</title>
		<link>http://www.apparitor.info/2011/04/06/apache-worker%e6%a8%a1%e5%bc%8f/</link>
		<comments>http://www.apparitor.info/2011/04/06/apache-worker%e6%a8%a1%e5%bc%8f/#comments</comments>
		<pubDate>Wed, 06 Apr 2011 06:44:25 +0000</pubDate>
		<dc:creator>gjw_apparitor</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[apache]]></category>

		<guid isPermaLink="false">http://www.apparitor.info/?p=223</guid>
		<description><![CDATA[ServerLimit 50 apache 进程数上限 ThreadLimit 110 apache 线程数上限 StartServers 5 apache 启动时默认建立的进程数 MaxClients 5000 最大并发数 MinSpareThreads 25 最小线程空闲数 MaxSpareThreads 200 最大线程空闲数 ThreadsPerChild 100 每个进程最多开启的线程 MaxRequestsPerChild 5000 指令用于控制服务器建立新进程和结束旧进程的频率 MaxRequestsPerChild 等于 MaxSpareThreads 或者 等于0 没有限制 最好不要设置为0防止内存溢出把服务拖死。 ServerLimit 大于 MaxClients/ThreadsPerChild ThreadLimit 大于 MaxClients/ServerLimit MaxSpareThreads 大于 ThreadsPerChild 原创文章，转载请注明： 转载自gjw_apparitor 博客 本文链接地址: apache worker模式]]></description>
			<content:encoded><![CDATA[<p>ServerLimit         	 	50        	apache 进程数上限<br />
ThreadLimit          		110       	apache 线程数上限<br />
StartServers         		5         	apache 启动时默认建立的进程数<br />
MaxClients           		5000   	最大并发数<br />
MinSpareThreads      	25        	最小线程空闲数<br />
MaxSpareThreads      	200       	最大线程空闲数<br />
ThreadsPerChild      	100      	每个进程最多开启的线程<br />
MaxRequestsPerChild  5000      指令用于控制服务器建立新进程和结束旧进程的频率</p>
<p>MaxRequestsPerChild 等于 MaxSpareThreads  或者 等于0 没有限制 最好不要设置为0防止内存溢出把服务拖死。<br />
ServerLimit 大于 MaxClients/ThreadsPerChild<br />
ThreadLimit 大于 MaxClients/ServerLimit<br />
MaxSpareThreads 大于 ThreadsPerChild
<div style="margin-top: 15px; font-style: italic">
<p><strong>原创文章，转载请注明：</strong> 转载自<a href="http://www.apparitor.info/">gjw_apparitor 博客</a></p>
<p><strong>本文链接地址:</strong> <a href="http://www.apparitor.info/2011/04/06/apache-worker%e6%a8%a1%e5%bc%8f/">apache worker模式</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.apparitor.info/2011/04/06/apache-worker%e6%a8%a1%e5%bc%8f/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>解决 Nginx处理404的SSI页面跳转的问题。</title>
		<link>http://www.apparitor.info/2011/04/06/%e8%a7%a3%e5%86%b3-nginx%e5%a4%84%e7%90%86404%e7%9a%84ssi%e9%a1%b5%e9%9d%a2%e8%b7%b3%e8%bd%ac%e7%9a%84%e9%97%ae%e9%a2%98%e3%80%82-2/</link>
		<comments>http://www.apparitor.info/2011/04/06/%e8%a7%a3%e5%86%b3-nginx%e5%a4%84%e7%90%86404%e7%9a%84ssi%e9%a1%b5%e9%9d%a2%e8%b7%b3%e8%bd%ac%e7%9a%84%e9%97%ae%e9%a2%98%e3%80%82-2/#comments</comments>
		<pubDate>Wed, 06 Apr 2011 06:42:50 +0000</pubDate>
		<dc:creator>gjw_apparitor</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[ssi]]></category>

		<guid isPermaLink="false">http://www.apparitor.info/?p=221</guid>
		<description><![CDATA[如果你的页面里SSI文件是用 “include virtual=”着种方式嵌套进去的。 你又配置了,错误页面跳转。 error_page 404 404.html 当你嵌套的页面不存在的时候就会发生整个页面变成404跳到404.html下了。 我们着一个技术很牛的同事想到的。 解决： 再域名的根目录创建个文本文件，里边的内容随意。我的是： echo &#8216;&#8216; > ssi_404.txt 再nginx的配置文件里加上： location ~* \.shtml$ { error_page 404 ssi_404.txt; } 这样有404的ssi页面就会显示这个内容，从而不会跳到404.html去了。 原创文章，转载请注明： 转载自gjw_apparitor 博客 本文链接地址: 解决 Nginx处理404的SSI页面跳转的问题。]]></description>
			<content:encoded><![CDATA[<p>如果你的页面里SSI文件是用 “include virtual=”着种方式嵌套进去的。<br />
    你又配置了,错误页面跳转。<br />
            error_page 404 404.html<br />
    当你嵌套的页面不存在的时候就会发生整个页面变成404跳到404.html下了。</p>
<p>    我们着一个技术很牛的同事想到的。 </p>
<p>   解决：</p>
<p>             再域名的根目录创建个文本文件，里边的内容随意。我的是：<br />
             echo &#8216;<!-- SSI Not Found -->&#8216; > ssi_404.txt</p>
<p>            再nginx的配置文件里加上：<br />
		location  ~* \.shtml$ {<br />
			error_page 404 ssi_404.txt;<br />
		}</p>
<p>           这样有404的ssi页面就会显示<!-- SSI Not Found -->这个内容，从而不会跳到404.html去了。
<div style="margin-top: 15px; font-style: italic">
<p><strong>原创文章，转载请注明：</strong> 转载自<a href="http://www.apparitor.info/">gjw_apparitor 博客</a></p>
<p><strong>本文链接地址:</strong> <a href="http://www.apparitor.info/2011/04/06/%e8%a7%a3%e5%86%b3-nginx%e5%a4%84%e7%90%86404%e7%9a%84ssi%e9%a1%b5%e9%9d%a2%e8%b7%b3%e8%bd%ac%e7%9a%84%e9%97%ae%e9%a2%98%e3%80%82-2/">解决 Nginx处理404的SSI页面跳转的问题。</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.apparitor.info/2011/04/06/%e8%a7%a3%e5%86%b3-nginx%e5%a4%84%e7%90%86404%e7%9a%84ssi%e9%a1%b5%e9%9d%a2%e8%b7%b3%e8%bd%ac%e7%9a%84%e9%97%ae%e9%a2%98%e3%80%82-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>解决 php-fpm 504 Gateway Time-out</title>
		<link>http://www.apparitor.info/2011/04/06/%e8%a7%a3%e5%86%b3-php-fpm-504-gateway-time-out/</link>
		<comments>http://www.apparitor.info/2011/04/06/%e8%a7%a3%e5%86%b3-php-fpm-504-gateway-time-out/#comments</comments>
		<pubDate>Wed, 06 Apr 2011 06:41:04 +0000</pubDate>
		<dc:creator>gjw_apparitor</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[fastcgi]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://www.apparitor.info/?p=219</guid>
		<description><![CDATA[我的Discuz 论坛 的apache+php 换成了nginx+fastcgi , 最近一到访问量高峰的时候就会出现： 504 Gateway Time-out 调整nginx配置文件如下： ＃ vi nginx.conf fastcgi_buffers 8 128K; send_timeout 60; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 128k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; fastcgi_intercept_errors on; 原创文章，转载请注明： 转载自gjw_apparitor 博客 本文链接地址: 解决 php-fpm 504 Gateway Time-out]]></description>
			<content:encoded><![CDATA[<p>我的Discuz 论坛 的apache+php 换成了nginx+fastcgi , 最近一到访问量高峰的时候就会出现：<br />
504 Gateway Time-out</p>
<p>调整nginx配置文件如下：</p>
<pre>＃ vi nginx.conf
    fastcgi_buffers                  8 128K;
    send_timeout                           60;
    fastcgi_connect_timeout         300;
    fastcgi_send_timeout             300;
    fastcgi_read_timeout              300;
    fastcgi_buffer_size                128k;
    fastcgi_busy_buffers_size     256k;
    fastcgi_temp_file_write_size 256k;
    fastcgi_intercept_errors            on;</pre>
<div style="margin-top: 15px; font-style: italic">
<p><strong>原创文章，转载请注明：</strong> 转载自<a href="http://www.apparitor.info/">gjw_apparitor 博客</a></p>
<p><strong>本文链接地址:</strong> <a href="http://www.apparitor.info/2011/04/06/%e8%a7%a3%e5%86%b3-php-fpm-504-gateway-time-out/">解决 php-fpm 504 Gateway Time-out</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.apparitor.info/2011/04/06/%e8%a7%a3%e5%86%b3-php-fpm-504-gateway-time-out/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nginx安装url_hash插件</title>
		<link>http://www.apparitor.info/2011/04/06/nginx%e5%ae%89%e8%a3%85url_hash%e6%8f%92%e4%bb%b6/</link>
		<comments>http://www.apparitor.info/2011/04/06/nginx%e5%ae%89%e8%a3%85url_hash%e6%8f%92%e4%bb%b6/#comments</comments>
		<pubDate>Wed, 06 Apr 2011 06:39:22 +0000</pubDate>
		<dc:creator>gjw_apparitor</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://www.apparitor.info/?p=217</guid>
		<description><![CDATA[简介： url_hash 是nginx的第三方模块，nginx本身不支持，需要打patch . Url_hash 你nginx在做负载均衡的时候。把转发的URL 以hash的形式保存。这样可以保证同一个URL始终 分给同一个real server，来提高访问速度。 为了确保能在 Nginx 中使用正则表达式进行更灵活的配置，安装之前需要确定系统是否安装有 PCRE（Perl Compatible Regular Expressions）包。您可以到 ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ 下载最新的 PCRE 源码包，使用下面命令下载编译和安装 PCRE 包： 软件列表： wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.7.tar.gz wget http://sysoev.ru/nginx/nginx-0.7.57.tar.gz wget http://wiki.nginx.org/images/7/78/Nginx_upstream_hash-0.3.tar.gz 1、下载软件 # cd /software/nginx/ # wget http://wiki.nginx.org/images/7/78/Nginx_upstream_hash-0.3.tar.gz # tar zxvf Nginx_upstream_hash-0.3.tar.gz # wget http://sysoev.ru/nginx/nginx-0.7.57.tar.gz # tar zxvf nginx-0.7.57.tar.gz # useradd nginx 2、给nginx 打 url_hash补丁。 # cat]]></description>
			<content:encoded><![CDATA[<p>简介：<br />
url_hash 是nginx的第三方模块，nginx本身不支持，需要打patch .<br />
Url_hash 你nginx在做负载均衡的时候。把转发的URL 以hash的形式保存。这样可以保证同一个URL始终<br />
分给同一个real server，来提高访问速度。<br />
为了确保能在 Nginx 中使用正则表达式进行更灵活的配置，安装之前需要确定系统是否安装有 PCRE（Perl Compatible Regular Expressions）包。您可以到 ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ 下载最新的 PCRE 源码包，使用下面命令下载编译和安装 PCRE 包：</p>
<p>软件列表：<br />
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.7.tar.gz<br />
wget http://sysoev.ru/nginx/nginx-0.7.57.tar.gz<br />
wget http://wiki.nginx.org/images/7/78/Nginx_upstream_hash-0.3.tar.gz</p>
<p><span id="more-217"></span><br />
1、下载软件</p>
<pre># cd /software/nginx/
# wget http://wiki.nginx.org/images/7/78/Nginx_upstream_hash-0.3.tar.gz
# tar zxvf Nginx_upstream_hash-0.3.tar.gz
# wget http://sysoev.ru/nginx/nginx-0.7.57.tar.gz
# tar zxvf nginx-0.7.57.tar.gz
# useradd nginx</pre>
<p>2、给nginx 打 url_hash补丁。</p>
<pre># cat nginx_upstream_hash-0.3/nginx.patch
diff -Naur src/http/ngx_http_upstream.h src-hash/http/ngx_http_upstream.h
--- src/http/ngx_http_upstream.h    2008-03-03 12:04:06.000000000 -0800
+++ src-hash/http/ngx_http_upstream.h    2008-06-07 13:01:37.000000000 -0700
@@ -90,6 +90,10 @@

     ngx_array_t                    *servers;   /* ngx_http_upstream_server_t */

+    ngx_array_t                    *values;
+    ngx_array_t                    *lengths;
+    ngx_uint_t                      retries;
+
     ngx_uint_t                      flags;
     ngx_str_t                       host;
     u_char                         *file_name;</pre>

<div class="wp_codebox"><table><tr id="p2174"><td class="line_numbers"><pre>0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code" id="p217code4"><pre class="text" style="font-family:monospace;"># vi nginx-0.7.57/src/http/ngx_http_upstream.h
struct ngx_http_upstream_srv_conf_s {
    ngx_http_upstream_peer_t         peer;
    void                           **srv_conf;
    ngx_array_t                     *servers; /* ngx_http_upstream_server_t */
    ngx_uint_t                       flags;
    ngx_str_t                        host;
    u_char                          *file_name;
    ngx_uint_t                       line;
    in_port_t                        port;
    in_port_t                        default_port;
};   
&nbsp;
改为：
struct ngx_http_upstream_srv_conf_s {
    ngx_http_upstream_peer_t         peer;
    void                           **srv_conf;
    ngx_array_t                     *servers; /* ngx_http_upstream_server_t */
&nbsp;
   ngx_array_t                    *values;
    ngx_array_t                    *lengths;
    ngx_uint_t                     retries;
&nbsp;
    ngx_uint_t                       flags;
    ngx_str_t                        host;
    u_char                          *file_name;
    ngx_uint_t                       line;
    in_port_t                        port;
    in_port_t                        default_port;
};</pre></td></tr></table></div>

<p>3、编译：nginx</p>
<pre># cd nginx-0.7.57
./configure --user=nginx \
--group=nginx \
--prefix=/webserver/nginx \
--with-http_stub_status_module \      #启用 nginx 的 NginxStatus 功能，用来监控 Nginx 的当前状态。
--with-http_ssl_module \
--without-http_rewrite_module \       #启用rewrite模块
--add-module=/software/nginx/nginx_upstream_hash-0.3    ＃url_hash模块的路径
# make
# make install     </pre>
<p>4、编写nginx配置文件</p>

<div class="wp_codebox"><table><tr id="p2175"><td class="line_numbers"><pre>0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
</pre></td><td class="code" id="p217code5"><pre class="text" style="font-family:monospace;"># vi /webserver/nginx/conf/nginx.conf
user nginx nginx;
worker_processes 10;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid        logs/nginx.pid;
worker_rlimit_nofile 51200;          #最大文件描述符
events
{
      use epoll;
      worker_connections 51200;
}
&nbsp;
http
{
      include       mime.types;
      default_type application/octet-stream;
      keepalive_timeout 120;
      tcp_nodelay on;
&nbsp;
      upstream www.gjw.com {
              server   10.10.11.121:80;        ＃这个是2台squid的机器
              server   10.10.11.122:80;
            hash $request_uri;                 ＃这个就是启用url_hash 功能
      }
&nbsp;
      server
      {
              listen 80;
              server_name www.gjw.com;
&nbsp;
              location / {
                       proxy_pass        http://www.gjw.com;
                       proxy_set_header   Host             $host;
                       proxy_set_header   X-Real-IP        $remote_addr;
                       proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
              }
&nbsp;
              log_format www_gjw_com '$remote_addr - $remote_user [$time_local] $request '
                                '&quot;$status&quot; $body_bytes_sent &quot;$http_referer&quot; '
                                '&quot;$http_user_agent&quot; &quot;$http_x_forwarded_for&quot;';
              access_log /data1/logs/www.log www_gjw_com;
&nbsp;
       location /nginx_status {
                      stub_status on;                                ＃这个是观察nginx情况的配置。
                   access_log   off;
                }
   }
}</pre></td></tr></table></div>

<p>启动nginx服务</p>
<pre># /webserver/nginx/sbin/nginx</pre>
<p>3、测试:<br />
找一台机器，在hosts里绑定IP地址，10.10.10.123为nginx的的IP。</p>

<div class="wp_codebox"><table><tr id="p2176"><td class="line_numbers"><pre>0
1
</pre></td><td class="code" id="p217code6"><pre class="text" style="font-family:monospace;"># vi /etc/hosts
10.10.11.123 www.gjw.com</pre></td></tr></table></div>

<p>找几个URL 测试一下，你会发现同一个url 都会解析到同一台机器上。</p>
<p>缺点：<br />
    我把其中一台squid 宕掉，原来分给他的URL 还是会找这台机器,造成503。
<div style="margin-top: 15px; font-style: italic">
<p><strong>原创文章，转载请注明：</strong> 转载自<a href="http://www.apparitor.info/">gjw_apparitor 博客</a></p>
<p><strong>本文链接地址:</strong> <a href="http://www.apparitor.info/2011/04/06/nginx%e5%ae%89%e8%a3%85url_hash%e6%8f%92%e4%bb%b6/">Nginx安装url_hash插件</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.apparitor.info/2011/04/06/nginx%e5%ae%89%e8%a3%85url_hash%e6%8f%92%e4%bb%b6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

