<?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; apache</title>
	<atom:link href="http://www.raptium.net/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.raptium.net</link>
	<description>raptium's another weblog</description>
	<lastBuildDate>Mon, 06 Sep 2010 08:53:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<atom:link rel='hub' href='http://www.raptium.net/?pushpress=hub'/>
		<item>
		<title>校内出错的那几分钟</title>
		<link>http://www.raptium.net/2009/03/27/bad-gateway-to-xiaonei/</link>
		<comments>http://www.raptium.net/2009/03/27/bad-gateway-to-xiaonei/#comments</comments>
		<pubDate>Fri, 27 Mar 2009 16:22:58 +0000</pubDate>
		<dc:creator>raptium</dc:creator>
				<category><![CDATA[瞎折腾]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[校内]]></category>
		<guid isPermaLink="false">http://www.raptium.com/?p=329</guid>
		<description><![CDATA[貌似最近通过搜索 校内 502 Bad Gateway 来到此页面的同学越来越多了。简单明了的告诉你，这是校内的服务器不行了，不是用户的问题，也许等等就好了，如果等等也不好……那……校内，你倒... ]]></description>
			<content:encoded><![CDATA[<blockquote><p>貌似最近通过搜索 <strong>校内 502 Bad Gateway</strong> 来到此页面的同学越来越多了。简单明了的告诉你，这是校内的服务器不行了，不是用户的问题，也许等等就好了，如果等等也不好……那……校内，你倒底行不行啊？ <em>&#8212; Updated on 2 Jun, 2009</em></p></blockquote>
<p>晚上开着校内的时候，突然弹了个框出来，说是 502 Bad Gateway，然后按刷新就看不到校内了，看到了……我熟悉的 nginx 502 错误页面～ 当时就想，校内又出错了啊，还是 nginx，可以研究一下哈。</p>
<p>立刻问了一下小野猪，他说校内是可以上的，就是有点慢。而我却是立刻返回 502 页面，服务器 nginx 0.6.32，校内正常的服务器应该是 resin 才对。两个人访问结果不同的情况，除了我 RP 差之外，还是有其他原因的，我猜就是我这两天碰巧在搞得 DNS Round Robin</p>
<pre>$ nslookup xiaonei.com
Server:        208.67.222.222
Address:    208.67.222.222#53
Non-authoritative answer:
Name:    xiaonei.com
Address: 211.157.20.6
Name:    xiaonei.com
Address: 211.157.20.3
Name:    xiaonei.com
Address: 211.157.20.2</pre>
<p>和 google.com 一样，xiaonei.com 解析的时候也会有三个 IP，DNS Server 会在每次回复的时候改变顺序，不过究竟用哪个 IP 还是客户端说了算，有时候 DNS Cache 久了，你可能长时间使用一个 IP 访问。不过这个在减低服务器负载上还是有效果的，因为人多了之后，还是大致上 IP 均分的。</p>
<p>DNS Round Robin  的实现是很容易，然后也有很大的弊端：由于 DNS propagation delay 通常要很久，几十分钟到几个小时甚至几天都有可能，所以如果一个服务器要临时下线的话，客户端是不知道这一情况的，还是会继续访问那个 IP，并不会被自动分流到好得 IP 上去。当然还是可以在 router/firewall 上把下线的 IP 分给某一台在线的服务器，不过要做到完全平滑过渡似乎是不大可能了（你至少得把所有 TCP 连接给断开才能改吧？）</p>
<p>回到校内这个问题上来…… 我试着反复清空 DNS cache，情况是，有一个 IP 返回 502，两个 IP 是好的，之后似乎情况又有变化，甚至有一段时间有两个 IP 是 502…… 于是猜测校内在重启 back-end server，但由于 DNS round robin 并不能解决平滑过渡的问题，即使是三只服务器依次重启，我还是遇到了出错的页面。</p>
<p>至于 nginx 的出现，我并不觉得惊讶，因为 nginx 的优秀性能总能让用它的人从中受益，校内可能省了点硬件的钱，我们则得到更好的用户体验～ 对于校内背后的服务器结构，我依旧迷惑。最外层是 squid，直接打 IP 就能看出来，而且即使 nginx 报 502 的时候，同一个 IP 还是能看到 squid，所以 squid 是最外层。然后是 nginx，可是再里面呢？resin？如果用 nginx 做 reverse proxy 的话，他的 server tag 是不会变的，永远都会自称 nginx，这个和 Apache 不同， Apache mod_proxy 做 reverse proxy 的话，server tag 是显示的 back-end server 的 server tag。于是迷惑了，更加奇怪的是，既然用到了 nginx，为什么校内的静态图片却是在 Apache 上呢…… 也许要等下次，下下次，不知道多少次校内出错的时候才能猜出来了～～</p>
<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li><a href="http://www.raptium.net/2009/03/05/china-will-never-innovate/" title="中国人只会山寨？">中国人只会山寨？</a></li><li><a href="http://www.raptium.net/2008/11/27/ubuntu-nginx-mysql-php-config/" title="[配置笔记]Ubuntu + nginx + MySQL + PHP">[配置笔记]Ubuntu + nginx + MySQL + PHP</a></li><li><a href="http://www.raptium.net/2009/05/01/wordpress-rewrite-rule-for-nginx/" title="nginx 的 wordpress rewrite 规则">nginx 的 wordpress rewrite 规则</a></li><li><a href="http://www.raptium.net/2009/05/01/centos-nginx-php-config-howto/" title="[配置笔记]CentOS + nginx + PHP">[配置笔记]CentOS + nginx + PHP</a></li><li><a href="http://www.raptium.net/2009/02/23/who-stole-my-ip/" title="ARP 擒贼记">ARP 擒贼记</a></li><li><a href="http://www.raptium.net/2009/01/19/initd-script-for-nginx-redhat/" title="init.d script for nginx, RedHat">init.d script for nginx, RedHat</a></li><li><a href="http://www.raptium.net/2009/01/14/nginx-awstats-or-not/" title="nginx, AWStats or Not?">nginx, AWStats or Not?</a></li><li><a href="http://www.raptium.net/2008/06/26/let-us-copy-with-xiaonei-api/" title="校内开放API：让我们一起抄袭？">校内开放API：让我们一起抄袭？</a></li><li><a href="http://www.raptium.net/2007/07/14/fanfou%e5%a5%bd%e5%a5%bd%e5%ad%a6%e4%b9%a0%ef%bc%8c%e5%a4%a9%e5%a4%a9%e6%a0%a1%e5%86%85/" title="fanfou=好好学习，天天校内">fanfou=好好学习，天天校内</a></li><li><a href="http://www.raptium.net/2007/06/22/%e6%8a%8a%e9%a5%ad%e5%90%a6%e6%b7%bb%e5%8a%a0%e5%88%b0%e6%a0%a1%e5%86%85%e7%9a%84%e7%ae%80%e5%8d%95%e6%96%b9%e6%b3%95/" title="把饭否添加到校内的简单方法">把饭否添加到校内的简单方法</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.raptium.net/2009/03/27/bad-gateway-to-xiaonei/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>中国人只会山寨？</title>
		<link>http://www.raptium.net/2009/03/05/china-will-never-innovate/</link>
		<comments>http://www.raptium.net/2009/03/05/china-will-never-innovate/#comments</comments>
		<pubDate>Fri, 06 Mar 2009 04:32:52 +0000</pubDate>
		<dc:creator>raptium</dc:creator>
				<category><![CDATA[唠唠叨叨]]></category>
		<category><![CDATA[瞎折腾]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[山寨]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[QQ]]></category>
		<category><![CDATA[QZHTTP]]></category>
		<guid isPermaLink="false">http://www.raptium.com/?p=321</guid>
		<description><![CDATA[开始有个习惯每个月看看 NetCraft 的 Web Server Survey，了解一下最新的服务器发展。通常总是那么几个产品上下沉浮，感觉也就和看浏览器市场占有率差不多。却没有浏览器竞争来的激烈，服务器... ]]></description>
			<content:encoded><![CDATA[<p>开始有个习惯每个月看看 NetCraft 的 Web Server Survey，了解一下最新的服务器发展。通常总是那么几个产品上下沉浮，感觉也就和看浏览器市场占有率差不多。却没有浏览器竞争来的激烈，服务器排名也没那么好看。</p>
<p>和浏览器不同的是，服务器可以是独家享用的，Google 的 GFE 就是占据 第三的宝座，却不能让外人尝鲜。这也说明 Google 的强大，看了报告总是想，他一家公司做的服务器，自家用，竟然能排到第三</p>
<p>然而，2月的报告出来看了感觉很雷……真的，真的是雷了。Google 的第三没了……给腾讯抢走了……竟然，是腾讯！仔细看看倒也觉得不出奇了，腾讯出了个自称是 QZHTTP 的 Web Server，然后把旗下 QZone 的网站都给换上了 QZHTTP。NetCraft 的统计是按照域名算的，而 QZone 是无数子域名的泛解析，我不知道是不是每个 QQ 用户都会自动拥有 QZone 的子域名，反正这一下子就是来了2千万个域名，nginx 说是发展很快，出道这几年也才有3百万个站点……</p>
<p>于是大家的好奇心也就不在这“为啥有这么多站点”上面，而是，QZHTTP 到底是个什么东西？略加搜索，在某外国友人的博客找到<a href="http://opendotdotdot.blogspot.com/2009/02/chinese-web-servers-are-coming.html">此文</a>。</p>
<p>外国人也是关心 QZHTTP 的，不过他们会比我们多想一点，就是，怎么是“中国人”做了个牛逼服务器出来？于是激烈的讨论也就展开了。所谓激烈，自然是有各种观点，基本分了这么几类：</p>
<ul>
<li> <strong>技术</strong>派：QZHTTP 不知道用了啥技术，也许就是换了名字的 Apache？IIS都有可能啊。拿各种软件测一下，好像是 thttpd？不过在没有可靠信息的情况下，也不能乱说。我宁愿知道更多有关的信息啊。</li>
<li> <strong>中国人爱山寨</strong>派：QZHTTP，呸！明显是山寨的 Apache 啊，中国人 Windows 用盗版的，迪士尼乐园有山寨的，Web Server 肯定也是假的！</li>
<li> <strong>国货当自强</strong>派：我就是腾讯的！QZHTTP 就是我们自己写的，和 Apache 什么开源软件，通通没有关系！</li>
<li> <strong>“中国人都不行”之无逻辑</strong>派：中国人能写 Web Server？那牛奶里怎么会有三聚氰胺的？</li>
<li> <strong>“楼上某些人法盲”</strong>派：你们想什么啊，抄就抄呗，开源的 License 只规定，改了之后如果发布出去，才需要公开代码。人家只是改了自己用，给别人提供服务，那就不用公开源代码啊。那明明是合法的嘛。法盲们，回家好好看看那些 License 吧～</li>
<li> <strong>“对对！中国人都不行”之反语</strong>派：是啊是啊，中国人都不行，完全不懂创新，只会抄袭。什么指南针、印刷术、火药、造纸术，通通都是抄的。开源软件的协议里都写了嘛，本软件的代码大家随便看，随便改，就是中国人不行～</li>
</ul>
<p>对于 QZHTTP 和相关讨论，我的观点和认识是：</p>
<ul>
<li>QZHTTP 应该不是简单的 Apache 换了名字。我想腾讯没有必要这么做，因为 qq.com 还是用的 Apache，而用 Apache 不是什么丢人的事，除非腾讯玩非主流～</li>
<li>自称来自腾讯的某人说法太过绝对了一点。has nothing to do with 说的轻松，我不否认腾讯有能力写一个自己的 Web Server，但是我觉得一个程序员在开始写 Web Server  之前没有好好研究过 Apache 或者其他优秀的开源项目就动手，是难以令人置信的。</li>
<li>中国人的不注意知识产权以及食品安全问题，早已伤害了各国人民的感情，也许脆弱的不仅仅是我们，但最后受伤的还是我们。</li>
<li>老祖宗创造四大发明的那个时代已经远去，要证明中国人除了山寨还是会创新，或者山寨也是另一种创新，这都得靠我们自己。</li>
</ul>
<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li><a href="http://www.raptium.net/2009/03/27/bad-gateway-to-xiaonei/" title="校内出错的那几分钟">校内出错的那几分钟</a></li><li><a href="http://www.raptium.net/2008/11/27/ubuntu-nginx-mysql-php-config/" title="[配置笔记]Ubuntu + nginx + MySQL + PHP">[配置笔记]Ubuntu + nginx + MySQL + PHP</a></li><li><a href="http://www.raptium.net/2009/11/18/tencen/" title="腾讯宣讲会">腾讯宣讲会</a></li><li><a href="http://www.raptium.net/2009/06/09/is-google-translato-toolkit-a-plot/" title="协同翻译工具之阴谋论">协同翻译工具之阴谋论</a></li><li><a href="http://www.raptium.net/2009/05/01/wordpress-rewrite-rule-for-nginx/" title="nginx 的 wordpress rewrite 规则">nginx 的 wordpress rewrite 规则</a></li><li><a href="http://www.raptium.net/2009/05/01/centos-nginx-php-config-howto/" title="[配置笔记]CentOS + nginx + PHP">[配置笔记]CentOS + nginx + PHP</a></li><li><a href="http://www.raptium.net/2009/02/23/who-stole-my-ip/" title="ARP 擒贼记">ARP 擒贼记</a></li><li><a href="http://www.raptium.net/2009/01/19/initd-script-for-nginx-redhat/" title="init.d script for nginx, RedHat">init.d script for nginx, RedHat</a></li><li><a href="http://www.raptium.net/2009/01/14/nginx-awstats-or-not/" title="nginx, AWStats or Not?">nginx, AWStats or Not?</a></li><li><a href="http://www.raptium.net/2008/04/24/where-is-the-torch/" title="火炬在哪里？">火炬在哪里？</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.raptium.net/2009/03/05/china-will-never-innovate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[配置笔记]Ubuntu + nginx + MySQL + PHP</title>
		<link>http://www.raptium.net/2008/11/27/ubuntu-nginx-mysql-php-config/</link>
		<comments>http://www.raptium.net/2008/11/27/ubuntu-nginx-mysql-php-config/#comments</comments>
		<pubDate>Wed, 26 Nov 2008 16:49:08 +0000</pubDate>
		<dc:creator>raptium</dc:creator>
				<category><![CDATA[瞎折腾]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Web Application Development]]></category>
		<guid isPermaLink="false">http://www.raptium.cn/?p=210</guid>
		<description><![CDATA[本来想写个How-To的，但是突然觉得自己没有功力教会别人，所以就不做标题党了。配置笔记，基本上是记录给自己看得，能够给别人有所帮助就更好了～ 最近不断的看到有关 nginx 的消息，基本... ]]></description>
			<content:encoded><![CDATA[<p><em>本来想写个How-To的，但是突然觉得自己没有功力教会别人，所以就不做标题党了。配置笔记，基本上是记录给自己看得，能够给别人有所帮助就更好了～</em></p>
<p>最近不断的看到有关 nginx 的消息，基本上都是正面的，看起来性能非常好。对于性能好的东西，我通常有一种莫名的恐惧，因为这些高级货一是要用到好的硬件上，二是配置复杂，如果还有三的话，那就是我通常不需要这么高的性能。然而这次稍稍看多了些 nginx 的介绍，其实它还是轻量级的，出道也不久，却能够被不少网站重用。俄罗斯人写的程序，作者自称英文较差，不过文档却也有了多国语言版，看来这东西真是受世界各国人民的喜爱啊～</p>
<p>晚上不想玩WoW，就装了个虚拟机，搞了 nginx 玩玩，记录如下。<span id="more-210"></span></p>
<p>配置表</p>
<ul>
<li>OS: Ubuntu Linux 8.10 Server</li>
<li>Web Server: nginx 0.6.33</li>
<li>Database Server: MySQL （apt源里的版本）</li>
<li>PHP: php-cgi （apt源里的版本）</li>
</ul>
<p>装系统，不用多说。我是装在虚拟机里的，刚开始用的VirtualBox，不过装好后出现了问题。因为Ubuntu Server的默认内核把PAE编译进去了，但是VirtualBox并不支持虚拟CPU的PAE功能，于是装好后不能启动。网上有关解决方案是修复模式下装其他内核，我发现这样又遇到更多问题……于是放弃。改用VMWare，一切安好。</p>
<p>Ubuntu基本上就用默认安装了，在选要什么Package的时候，除了OpenSSH Server，其他可以都不用选。真要选LAMP也行，不过到时候还是要把Apache给关掉～</p>
<p>系统装好后，老习惯</p>
<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">sudo apt-get update
sudo apt-get upgrade</pre></div></div>
<p>Ubuntu 8.10 发布没多久，不需要下多少更新，几分钟搞定。<br />
然后准备下载编译 nginx ，不过在此之前我们要把编译环境设好。</p>
<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">sudo apt-get install build-essential libpcre3-dev libssl-dev</pre></div></div>
<p>最短命令就这样了，会自动加上一堆dependency的，都按y就行了。</p>
<p>之后是下载编译，nginx 似乎已经出到 0.7.x 了，不过这是第一次弄，我还是选择了stable的 0.6.33</p>
<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">wget http://sysoev.ru/nginx/nginx-0.6.33.tar.gz
tar zxvf nginx-0.6.33.tar.gz
cd nginx-0.6.33
./configure --sbin-path=/usr/local/sbin --with-http_ssl_module
make
sudo make install</pre></div></div>
<p>至此 nginx 安装完毕。如果现在运行 nginx 的话，应该可以看到简陋的欢迎页面了，不过先不急，搞定别的先～</p>
<p>安装 PHP，</p>
<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">sudo apt-get install php5-cgi</pre></div></div>
<p>因为在 nginx 上 PHP 必须以 FastCGI 的方式运行，所以就直接装这个包了。但是 nginx 有没有自己运行 CGI 的机制，所以还需要用到 spawn-fcgi 这个小程序。这是 lighttpd 里面带的，不过为了它我们并不需要装整个 lighttpd，自己编译一个 lighttpd 然后取出这个程序单独用就好了～</p>
<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">wget http://www.lighttpd.net/download/lighttpd-1.4.20.tar.gz
tar zxvf lighttpd-1.4.20
./configure
make
sudo cp src/spawn-fcgi /usr/local/bin/spawn-fcgi</pre></div></div>
<p><span style="text-decoration: line-through;">[明天继续update...]</span></p>
<p>我在公司的另一项任务中也用到了 nginx， 或许之后会另写文章记录配置过程。</p>
<p><strong>Reference</strong></p>
<ul>
<li><a href="http://articles.slicehost.com/2007/12/3/ubuntu-gutsy-installing-nginx-from-source">Ubuntu Gutsy &#8211; Installing Nginx from source</a></li>
</ul>
<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li><a href="http://www.raptium.net/2009/05/01/centos-nginx-php-config-howto/" title="[配置笔记]CentOS + nginx + PHP">[配置笔记]CentOS + nginx + PHP</a></li><li><a href="http://www.raptium.net/2009/03/27/bad-gateway-to-xiaonei/" title="校内出错的那几分钟">校内出错的那几分钟</a></li><li><a href="http://www.raptium.net/2009/03/05/china-will-never-innovate/" title="中国人只会山寨？">中国人只会山寨？</a></li><li><a href="http://www.raptium.net/2009/02/23/who-stole-my-ip/" title="ARP 擒贼记">ARP 擒贼记</a></li><li><a href="http://www.raptium.net/2009/01/19/initd-script-for-nginx-redhat/" title="init.d script for nginx, RedHat">init.d script for nginx, RedHat</a></li><li><a href="http://www.raptium.net/2009/05/01/wordpress-rewrite-rule-for-nginx/" title="nginx 的 wordpress rewrite 规则">nginx 的 wordpress rewrite 规则</a></li><li><a href="http://www.raptium.net/2009/01/14/nginx-awstats-or-not/" title="nginx, AWStats or Not?">nginx, AWStats or Not?</a></li><li><a href="http://www.raptium.net/2008/09/08/cappuccino/" title="Cappuccino小试">Cappuccino小试</a></li><li><a href="http://www.raptium.net/2007/07/14/fanfou%e5%a5%bd%e5%a5%bd%e5%ad%a6%e4%b9%a0%ef%bc%8c%e5%a4%a9%e5%a4%a9%e6%a0%a1%e5%86%85/" title="fanfou=好好学习，天天校内">fanfou=好好学习，天天校内</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.raptium.net/2008/11/27/ubuntu-nginx-mysql-php-config/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
