<?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>Justin's Tech Blog &#187; Lighttpd</title>
	<atom:link href="http://www.sofee.cn/blog/category/technical/lighttpd/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sofee.cn/blog</link>
	<description>世界其实很简单，复杂的是人；生活其实很轻松，沉重的是感情！</description>
	<lastBuildDate>Sun, 17 Jan 2010 17:17:22 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>高负载WEB动态页面与静态页面的分离</title>
		<link>http://www.sofee.cn/blog/2006/10/19/47/</link>
		<comments>http://www.sofee.cn/blog/2006/10/19/47/#comments</comments>
		<pubDate>Thu, 19 Oct 2006 15:36:52 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Lighttpd]]></category>
		<category><![CDATA[mod_cache]]></category>
		<category><![CDATA[mod_proxy]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[性能]]></category>

		<guid isPermaLink="false">http://www.sofee.cn/blog/?p=47</guid>
		<description><![CDATA[试了一段时间的Lighttpd，表现的确不错，原先用APACHE只能跑到6K/S，改用Lighttpd后性能提升了将近一倍，只是跑PHP似乎很不稳定，数据库处理时间长一点就会到导致Lighttpd出现500的错误，也就是说要想使Lighttpd发挥更好的性能，除了优化程序还是优化程序，尽可能的加快PHP的执行速度，另外加上eAccelerator性能会有更大的提高。
说了这么多优点，再来说说公司最近所尝试的一些经验，PHP程序已被优化的不能再优化了，但是有时候操作一下数据库（比如执行mysqldump）就会出现500错误，并发量非常大的时候很容易出现，在这点上Lighttpd的表现就没有Apache稳定了，所以想了一个折中的办法，让Apache来处理PHP程序，其他的静态页面（包括图片、软件等等）全都交给Lighttpd来处理。而实现方法就是通过mod_proxy来实现，Apache做前端处理或Lighttpd做前端处理都行，反正这2种都有个mod_proxy模块，基本上一样。

下面就以CentOS 4.4系统下使用Apache（80端口）和Lighttpd（81端口）实现动态页面和静态页面的分离。
Apache采用系统默认安装（yum install apache）的即可，网上的安装文档也很多，偶就不再介绍了。
安装Lighttpd v1.4.13

# yum install pcre-devel
# cd /usr/local/src
# wget http://www.lighttpd.net/download/lighttpd-1.4.13.tar.gz
# tar -zxvf lighttpd-1.4.13.tar.gz
# cd lighttpd-1.4.13
# ./configure --with-pcre
# make
# make install
# cd doc
# cp sysconfig.lighttpd /etc/sysconfig/lighttpd
# cp rc.lighttpd.redhat /etc/init.d/lighttpd
# chkconfig lighttpd on
# mkdir -p /etc/lighttpd
# cp lighttpd.conf /etc/lighttpd/
# mkdir /var/log/lighttpd
# touch /var/log/lighttpd/access.log
# touch /var/log/lighttpd/error.log
# chown -R apache:apache /var/log/lighttpd


# vi /etc/init.d/lighttpd

将lighttpd=&#8221;/usr/sbin/lighttpd&#8221;改为lighttpd=&#8221;/usr/local/sbin/lighttpd&#8221;
编辑Lighttpd的配置文件lighttpd.conf，大致修改如下：

server.modules = ("mod_access", "mod_simple_vhost", "mod_accesslog" [...]]]></description>
		<wfw:commentRss>http://www.sofee.cn/blog/2006/10/19/47/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fix too many FIN_WAIT_2 connections under freebsd</title>
		<link>http://www.sofee.cn/blog/2006/08/26/33/</link>
		<comments>http://www.sofee.cn/blog/2006/08/26/33/#comments</comments>
		<pubDate>Sat, 26 Aug 2006 06:54:57 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Lighttpd]]></category>

		<guid isPermaLink="false">http://www.sofee.cn/blog/?p=33</guid>
		<description><![CDATA[ 
var alimama_pid="mm_10006029_103557_106167"; 
var alimama_titlecolor="8ab459"; 
var alimama_descolor ="888888"; 
var alimama_bgcolor="FFFFFF"; 
var alimama_bordercolor="ffffff"; 
var alimama_linkcolor="8ab459"; 
var alimama_sizecode="12"; 
var alimama_width=468; 
var alimama_height=60; 
var alimama_type=2; 
 
 
 查看FIN_WAIT_2连接数：

bsd#netstat -an &#124; grep FIN_WAIT_2 &#124; wc -l
2523

修改Lighttpd配置文件，加入下面这条语句：

server.max-keep-alive-requests = 0


bsd#netstat -an &#124; grep FIN_WAIT_2 &#124; wc -l
91

如果服务器开启了ipfw2防火墙的话，还需要执行：

sysctl -w net.inet.ip.fw.dyn_keepalive=0

p.s. 若为APACHE服务器，同理。

  addthis_url    = 'http%3A%2F%2Fwww.sofee.cn%2Fblog%2F2006%2F08%2F26%2F33%2F';
  addthis_title  [...]]]></description>
		<wfw:commentRss>http://www.sofee.cn/blog/2006/08/26/33/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
