<?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>ls /proc &#187; apache</title>
	<atom:link href="http://www.lsproc.com/blog/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lsproc.com/blog</link>
	<description>lsproc.com</description>
	<lastBuildDate>Fri, 21 May 2010 14:29:46 +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>一些有用apache重写规则</title>
		<link>http://www.lsproc.com/blog/useful_apache_urlrewrite/</link>
		<comments>http://www.lsproc.com/blog/useful_apache_urlrewrite/#comments</comments>
		<pubDate>Fri, 21 Mar 2008 08:36:09 +0000</pubDate>
		<dc:creator>lostsnow</dc:creator>
				<category><![CDATA[Linux&Webserver]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[url_rewrite]]></category>

		<guid isPermaLink="false">http://www.lostk.com/blog/useful_apache_urlrewrite/</guid>
		<description><![CDATA[转载时请标明文章原始出处和作者信息, 作者: lostsnow.http://www.lsproc.com/blog/useful_apache_urlrewrite/
# 将domain.com/xxx转向www.domain.com/xxx
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$  http://www.domain.com$1 [R=301,NC]

# 将xxx.domain.com/yyy...重定向到www.domain.com/xxx/yyy..., xxx 5-20位, 字母开头只含字母, 数字以及&#34;-&#34;和&#34;_&#34;
RewriteCond %{SERVER_NAME} ^([a-z][a-z0-9\-\_]{4,19})\.domain\.com [NC]
RewriteRule ^(.+)$ %{SERVER_NAME}$1 [C]
RewriteRule ^([a-z][a-z0-9\-\_]{4,19})\.domain\.com(.*)$ http://www.domain.com/$1$2 [R=301,NC]

# 将首页www.domain.com转向www.domain.com/html/index.html
RewriteCond %{HTTP_HOST} www\.domain\.com
RewriteRule ^/$  http://www.domain.com/html/index.html [R=301,L]

-- EOF --
Related Posts2008-10-23 -- nginx rewrite 的一些参数   (1)2008-03-18 -- lamp 相关配置 [Debian] (2)2008-03-05 -- apache下htaccess的Invalid command &#8216;AuthUserFile&#8217;错误 (0)2008-03-01 -- 如何关闭time_wait连接 (4)2007-12-10 [...]]]></description>
			<content:encoded><![CDATA[<p>转载时请标明文章原始出处和作者信息, 作者: <a href="http://www.lsproc.com/blog/">lostsnow</a>.<br /><a href="http://www.lsproc.com/blog/useful_apache_urlrewrite/">http://www.lsproc.com/blog/useful_apache_urlrewrite/</a></p>
<pre class="brush: text"># 将domain.com/xxx转向www.domain.com/xxx
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$  http://www.domain.com$1 [R=301,NC]

# 将xxx.domain.com/yyy...重定向到www.domain.com/xxx/yyy..., xxx 5-20位, 字母开头只含字母, 数字以及&quot;-&quot;和&quot;_&quot;
RewriteCond %{SERVER_NAME} ^([a-z][a-z0-9\-\_]{4,19})\.domain\.com [NC]
RewriteRule ^(.+)$ %{SERVER_NAME}$1 [C]
RewriteRule ^([a-z][a-z0-9\-\_]{4,19})\.domain\.com(.*)$ http://www.domain.com/$1$2 [R=301,NC]

# 将首页www.domain.com转向www.domain.com/html/index.html
RewriteCond %{HTTP_HOST} www\.domain\.com
RewriteRule ^/$  http://www.domain.com/html/index.html [R=301,L]
</pre>
<p>-- EOF --</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li>2008-10-23 -- <a href="http://www.lsproc.com/blog/nginx_rewrite_param/" title="nginx rewrite 的一些参数  ">nginx rewrite 的一些参数  </a> (1)</li><li>2008-03-18 -- <a href="http://www.lsproc.com/blog/configure_lamp/" title="lamp 相关配置 [Debian]">lamp 相关配置 [Debian]</a> (2)</li><li>2008-03-05 -- <a href="http://www.lsproc.com/blog/htaccess_error_on_apache/" title="apache下htaccess的Invalid command &#8216;AuthUserFile&#8217;错误">apache下htaccess的Invalid command &#8216;AuthUserFile&#8217;错误</a> (0)</li><li>2008-03-01 -- <a href="http://www.lsproc.com/blog/close_timewait_connection/" title="如何关闭time_wait连接">如何关闭time_wait连接</a> (4)</li><li>2007-12-10 -- <a href="http://www.lsproc.com/blog/apache2x_name_based_virtual_hosting/" title="Apache 2.x 基于主机名的虚拟主机">Apache 2.x 基于主机名的虚拟主机</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.lsproc.com/blog/useful_apache_urlrewrite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>lamp 相关配置 [Debian]</title>
		<link>http://www.lsproc.com/blog/configure_lamp/</link>
		<comments>http://www.lsproc.com/blog/configure_lamp/#comments</comments>
		<pubDate>Tue, 18 Mar 2008 08:35:41 +0000</pubDate>
		<dc:creator>lostsnow</dc:creator>
				<category><![CDATA[Linux&Webserver]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.lostk.com/blog/configure_lamp/</guid>
		<description><![CDATA[转载时请标明文章原始出处和作者信息, 作者: lostsnow.http://www.lsproc.com/blog/configure_lamp/
编译环境
Debian (Ubuntu)

apt-get install build-essential
apt-get install libncurses5-dev
sudo apt-get install libxml2-dev libcurl3-dev libpng-dev libmhash-dev libmcrypt-dev libxslt-dev libpspell-dev

Mysql编译安装参数
CHOST=&#34;i686-pc-linux-gnu&#34; CFLAGS=&#34;-O3 -msse2 -mmmx -mfpmath=sse -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer&#34; CXXFLAGS=&#34;-O3 -msse2 -mmmx -mfpmath=sse -funroll-loops -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer&#34; ./configure --prefix=/usr/local/mysql --localstatedir=/var/lib/mysql --with-comment=Source --with-server-suffix=-Community-Server --with-mysqld-user=mysql --without-debug --with-big-tables --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=all --with-pthread --enable-static --enable-thread-safe-client --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --enable-assembler --without-ndb-debug --without-isam --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock
配置成功会提示：
MySQL has [...]]]></description>
			<content:encoded><![CDATA[<p>转载时请标明文章原始出处和作者信息, 作者: <a href="http://www.lsproc.com/blog/">lostsnow</a>.<br /><a href="http://www.lsproc.com/blog/configure_lamp/">http://www.lsproc.com/blog/configure_lamp/</a></p>
<p>编译环境</p>
<p>Debian (Ubuntu)</p>
<pre class="brush: bash">
apt-get install build-essential
apt-get install libncurses5-dev
sudo apt-get install libxml2-dev libcurl3-dev libpng-dev libmhash-dev libmcrypt-dev libxslt-dev libpspell-dev
</pre>
<p><strong>Mysql编译安装参数</strong></p>
<pre class="brush: bash">CHOST=&quot;i686-pc-linux-gnu&quot; CFLAGS=&quot;-O3 -msse2 -mmmx -mfpmath=sse -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer&quot; CXXFLAGS=&quot;-O3 -msse2 -mmmx -mfpmath=sse -funroll-loops -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer&quot; ./configure --prefix=/usr/local/mysql --localstatedir=/var/lib/mysql --with-comment=Source --with-server-suffix=-Community-Server --with-mysqld-user=mysql --without-debug --with-big-tables --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=all --with-pthread --enable-static --enable-thread-safe-client --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --enable-assembler --without-ndb-debug --without-isam --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock</pre>
<p>配置成功会提示：</p>
<p>MySQL has a Web site athttp://www.mysql.com/which carries details on the<br />
latest release, upcoming features, and other information to make your<br />
work or play with MySQL more productive. There you can also find<br />
information about mailing lists for MySQL discussion.</p>
<p>Remember to check the platform. specific part of the reference manual for<br />
hints about installing MySQL on your platform. Also have a look at the<br />
files in the Docs directory.</p>
<p>Thank you for choosing MySQL!</p>
<pre class="brush: bash">
make
make install

groupadd mysql                     //增加mysql组
useradd -g mysql mysql         //增加mysql用户，这个用户属于mysql组
cd /usr/local/mysql
bin/mysql_install_db --user=mysql
chown -R root:mysql . //设置权限，注意后面有一个 &quot;.&quot;
chown -R mysql /var/lib/mysql //设置 mysql 目录权限
chgrp -R mysql . //注意后面有一个 &quot;.&quot;
cp share/mysql/my-medium.cnf /etc/my.cnf
cp share/mysql/mysql.server /etc/init.d/mysqld //开机自动启动 mysql。
chmod 755 /etc/init.d/mysqld
rcconf    //开启启动服务设置
/etc/init.d/mysqld start //启动 MySQL
bin/mysqladmin -u root password &quot;password_for_root&quot;
</pre>
<p><strong>查看mysql编译参数</strong><br />
cat /usr/local/mysql/bin/mysqlbug |grep ./configure</p>
<p>把 mysql 加入环境变量<br />
export PATH="$PATH:/usr/local/mysql/bin"</p>
<p>apache 编译</p>
<pre class="brush: bash">
./configure   //配置源代码树
--prefix=/usr/local/apache2  //体系无关文件的顶级安装目录PREFIX ，也就Apache的安装目录。
--enable-module=so   //打开 so 模块，so 模块是用来提 DSO 支持的 apache 核心模块
--enable-deflate=shared   //支持网页压缩
--enable-expires=shared   //支持 HTTP 控制
--enable-rewrite=shared   //支持 URL 重写
--enable-cache  //支持缓存
--enable-file-cache  //支持文件缓存
--enable-mem-cache  //支持记忆缓存
--enable-disk-cache //支持磁盘缓存
--enable-static-support   //支持静态连接(默认为动态连接)
--enable-static-htpasswd   //使用静态连接编译 htpasswd - 管理用于基本认证的用户文件
--enable-static-htdigest  //使用静态连接编译 htdigest - 管理用于摘要认证的用户文件
--enable-static-rotatelogs  //使用静态连接编译 rotatelogs - 滚动 Apache 日志的管道日志程序
--enable-static-logresolve   //使用静态连接编译 logresolve - 解析 Apache 日志中的IP地址为主机名
--enable-static-htdbm   //使用静态连接编译 htdbm - 操作 DBM 密码数据库
--enable-static-ab  //使用静态连接编译 ab - Apache HTTP 服务器性能测试工具
--enable-static-checkgid   //使用静态连接编译 checkgid
--disable-cgid  //禁止用一个外部 CGI 守护进程执行CGI脚本
--disable-cgi   //禁止编译 CGI 版本的 PHP
--disable-userdir  //禁止用户从自己的主目录中提供页面
--with-mpm=worker // 让apache以worker方式运行
--enable-authn-dbm=shared // 对动态数据库进行操作。Rewrite时需要。

make
make install
</pre>
<p>建立一个符号连接：</p>
<pre class="brush: bash">
ln -s /usr/local/apache2/bin/apachectl /etc/init.d/httpd
rcconf    //加入自动启动
</pre>
<p>php 编译</p>
<pre class="brush: bash">
CHOST=&quot;i686-pc-linux-gnu&quot; CFLAGS=&quot;-O3 -msse2 -mmmx -mfpmath=sse -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer&quot; CXXFLAGS=&quot;-O3 -msse2 -mmmx -mfpmath=sse -funroll-loops -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer&quot; ./configure --prefix=/usr/local/php5 --with-mysql=/usr/local/mysql --with-gd --enable-calendar --with-zlib --with-curl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-apxs2=/usr/local/apache2/bin/apxs --with-openssl --enable-zend-multibyte --with-gettext --with-mcrypt --enable-exif --with-png-dir=/usr/local/lib --enable-ftp --with-mhash --with-libxml-dir=/usr/local/lib --with-xsl --with-pspell
</pre>
<p>配置完成提示<br />
+--------------------------------------------------------------------+<br />
| License:                                                           |<br />
| This software is subject to the PHP License, available in this     |<br />
| distribution in the file LICENSE.  By continuing this installation |<br />
| process, you are bound by the terms of this license agreement.     |<br />
| If you do not agree with the terms of this license, you must abort |<br />
| the installation process at this point.                            |<br />
+--------------------------------------------------------------------+</p>
<p>Thank you for using PHP.</p>
<pre class="brush: bash">
make
make install
</pre>
<p>修改/usr/local/apache2/conf/httpd.conf，在AddType部分加入如下内容<br />
AddType application/x-httpd-php .php
<p>-- EOF --</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li>2006-08-22 -- <a href="http://www.lsproc.com/blog/trouble-with-rebuild-system/" title="重装系统是件麻烦的事">重装系统是件麻烦的事</a> (0)</li><li>2008-03-01 -- <a href="http://www.lsproc.com/blog/close_timewait_connection/" title="如何关闭time_wait连接">如何关闭time_wait连接</a> (4)</li><li>2007-09-07 -- <a href="http://www.lsproc.com/blog/php_mysql_study_4/" title="PHP 和 Mysql 学习笔记（四）">PHP 和 Mysql 学习笔记（四）</a> (0)</li><li>2007-06-22 -- <a href="http://www.lsproc.com/blog/php_mysql_study_2/" title="PHP 和 Mysql 学习笔记（二）">PHP 和 Mysql 学习笔记（二）</a> (0)</li><li>2010-05-21 -- <a href="http://www.lsproc.com/blog/nginx_php_pathinfo_securit/" title="Nginx/PHP 文件类型错误解析漏洞：fix_pathinfo">Nginx/PHP 文件类型错误解析漏洞：fix_pathinfo</a> (2)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.lsproc.com/blog/configure_lamp/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>apache下htaccess的Invalid command &#039;AuthUserFile&#039;错误</title>
		<link>http://www.lsproc.com/blog/htaccess_error_on_apache/</link>
		<comments>http://www.lsproc.com/blog/htaccess_error_on_apache/#comments</comments>
		<pubDate>Wed, 05 Mar 2008 09:28:10 +0000</pubDate>
		<dc:creator>lostsnow</dc:creator>
				<category><![CDATA[Linux&Webserver]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[身份验证]]></category>

		<guid isPermaLink="false">http://www.lostk.com/blog/htaccess_error_on_apache/</guid>
		<description><![CDATA[转载时请标明文章原始出处和作者信息, 作者: lostsnow.http://www.lsproc.com/blog/htaccess_error_on_apache/
使用了apache的 .htaccess做身份认证后, 无法访问
查看日志报错如下:
"Invalid command 'AuthUserFile', perhaps misspelled or defined by a module not included in the server configuration"
LoadModule auth_basic_module /usr/lib/apache2/modules/mod_auth_basic.so
LoadModule authz_owner_module /usr/lib/apache2/modules/mod_authz_owner.so
LoadModule authn_file_module  /usr/lib/apache2/modules/mod_authn_file.so
ok，问题解决
-- EOF --
Related Posts2008-03-21 -- 一些有用apache重写规则 (0)2008-03-18 -- lamp 相关配置 [Debian] (2)2008-03-01 -- 如何关闭time_wait连接 (4)2007-12-10 -- Apache 2.x 基于主机名的虚拟主机 (0)2007-06-02 -- QQ居然占用443端口 (9)]]></description>
			<content:encoded><![CDATA[<p>转载时请标明文章原始出处和作者信息, 作者: <a href="http://www.lsproc.com/blog/">lostsnow</a>.<br /><a href="http://www.lsproc.com/blog/htaccess_error_on_apache/">http://www.lsproc.com/blog/htaccess_error_on_apache/</a></p>
<p>使用了apache的 .htaccess做身份认证后, 无法访问<br />
查看日志报错如下:<br />
"Invalid command 'AuthUserFile', perhaps misspelled or defined by a module not included in the server configuration"</p>
<pre class="brush: text">LoadModule auth_basic_module /usr/lib/apache2/modules/mod_auth_basic.so
LoadModule authz_owner_module /usr/lib/apache2/modules/mod_authz_owner.so
LoadModule authn_file_module  /usr/lib/apache2/modules/mod_authn_file.so</pre>
<p>ok，问题解决
<p>-- EOF --</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li>2008-03-21 -- <a href="http://www.lsproc.com/blog/useful_apache_urlrewrite/" title="一些有用apache重写规则">一些有用apache重写规则</a> (0)</li><li>2008-03-18 -- <a href="http://www.lsproc.com/blog/configure_lamp/" title="lamp 相关配置 [Debian]">lamp 相关配置 [Debian]</a> (2)</li><li>2008-03-01 -- <a href="http://www.lsproc.com/blog/close_timewait_connection/" title="如何关闭time_wait连接">如何关闭time_wait连接</a> (4)</li><li>2007-12-10 -- <a href="http://www.lsproc.com/blog/apache2x_name_based_virtual_hosting/" title="Apache 2.x 基于主机名的虚拟主机">Apache 2.x 基于主机名的虚拟主机</a> (0)</li><li>2007-06-02 -- <a href="http://www.lsproc.com/blog/port_443_used_by_qq/" title="QQ居然占用443端口">QQ居然占用443端口</a> (9)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.lsproc.com/blog/htaccess_error_on_apache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>如何关闭time_wait连接</title>
		<link>http://www.lsproc.com/blog/close_timewait_connection/</link>
		<comments>http://www.lsproc.com/blog/close_timewait_connection/#comments</comments>
		<pubDate>Fri, 29 Feb 2008 16:35:58 +0000</pubDate>
		<dc:creator>lostsnow</dc:creator>
				<category><![CDATA[Linux&Webserver]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[netstat]]></category>
		<category><![CDATA[time_wait]]></category>

		<guid isPermaLink="false">http://www.lostk.com/blog/close_timewait_connection/</guid>
		<description><![CDATA[转载时请标明文章原始出处和作者信息, 作者: lostsnow.http://www.lsproc.com/blog/close_timewait_connection/
结合netstat和awk命令来统计网络连接数
From: http://hi.baidu.com/thinkinginlamp/blog/item/afbcab64b1ad81f3f6365453.html
netstat -n &#124; awk '/^tcp/ {++state[$NF]} END {for(key in state) print key,"\t",state[key]}'
会得到类似下面的结果，具体数字会有所不同：
LAST_ACK         1
SYN_RECV         14
ESTABLISHED      79
FIN_WAIT1        28
FIN_WAIT2        3
CLOSING [...]]]></description>
			<content:encoded><![CDATA[<p>转载时请标明文章原始出处和作者信息, 作者: <a href="http://www.lsproc.com/blog/">lostsnow</a>.<br /><a href="http://www.lsproc.com/blog/close_timewait_connection/">http://www.lsproc.com/blog/close_timewait_connection/</a></p>
<p>结合netstat和awk命令来统计网络连接数<br />
From: <a href="http://hi.baidu.com/thinkinginlamp/blog/item/afbcab64b1ad81f3f6365453.html">http://hi.baidu.com/thinkinginlamp/blog/item/afbcab64b1ad81f3f6365453.html</a></p>
<p><code>netstat -n | awk '/^tcp/ {++state[$NF]} END {for(key in state) print key,"\t",state[key]}'</code></p>
<p>会得到类似下面的结果，具体数字会有所不同：</p>
<blockquote><p>LAST_ACK         1<br />
SYN_RECV         14<br />
ESTABLISHED      79<br />
FIN_WAIT1        28<br />
FIN_WAIT2        3<br />
CLOSING          5<br />
TIME_WAIT        1669</p></blockquote>
<p>状态：描述<br />
CLOSED：无连接是活动的或正在进行<br />
LISTEN：服务器在等待进入呼叫<br />
SYN_RECV：一个连接请求已经到达，等待确认<br />
SYN_SENT：应用已经开始，打开一个连接<br />
ESTABLISHED：正常数据传输状态<br />
FIN_WAIT1：应用说它已经完成<br />
FIN_WAIT2：另一边已同意释放<br />
ITMED_WAIT：等待所有分组死掉<br />
CLOSING：两边同时尝试关闭<br />
TIME_WAIT：另一边已初始化一个释放<br />
LAST_ACK：等待所有分组死掉</p>
<p>也就是说，这条命令可以把当前系统的网络连接状态分类汇总。</p>
<p>下面解释一下为啥要这样写：</p>
<p>一个简单的管道符连接了netstat和awk命令。</p>
<p>------------------------------------------------------------------</p>
<p>先来看看netstat：</p>
<p><strong>netstat -n</strong></p>
<p>Active Internet connections (w/o servers)<br />
Proto Recv-Q Send-Q Local Address           Foreign Address         State<br />
tcp        0      0 123.123.123.123:80      234.234.234.234:12345   TIME_WAIT</p>
<p>你实际执行这条命令的时候，可能会得到成千上万条类似上面的记录，不过我们就拿其中的一条就足够了。</p>
<p>------------------------------------------------------------------</p>
<p>再来看看awk：</p>
<p><strong>/^tcp/</strong><br />
滤出tcp开头的记录，屏蔽udp, socket等无关记录。</p>
<p><strong>state[]</strong><br />
相当于定义了一个名叫state的数组</p>
<p><strong>NF</strong><br />
表示记录的字段数，如上所示的记录，NF等于6</p>
<p><strong>$NF</strong><br />
表示某个字段的值，如上所示的记录，$NF也就是$6，表示第6个字段的值，也就是TIME_WAIT</p>
<p><strong>state[$NF]</strong><br />
表示数组元素的值，如上所示的记录，就是state[TIME_WAIT]状态的连接数</p>
<p><strong>++state[$NF]</strong><br />
表示把某个数加一，如上所示的记录，就是把state[TIME_WAIT]状态的连接数加一</p>
<p><strong>END</strong><br />
表示在最后阶段要执行的命令</p>
<p><strong>for(key in state)</strong><br />
遍历数组</p>
<p><strong>print key,"\t",state[key]</strong><br />
打印数组的键和值，中间用\t制表符分割，美化一下。</p>
<p>如发现系统存在大量TIME_WAIT状态的连接，通过调整内核参数解决，<br />
<code>vim /etc/sysctl.conf</code><br />
编辑文件，加入以下内容：</p>
<pre class="brush: bash">net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_fin_timeout = 30</pre>
<p>然后执行 <code>/sbin/sysctl -p</code> 让参数生效。</p>
<p><strong>net.ipv4.tcp_syncookies = 1</strong> 表示开启SYN Cookies。当出现SYN等待队列溢出时，启用cookies来处理，可防范少量SYN攻击，默认为0，表示关闭；<br />
<strong>net.ipv4.tcp_tw_reuse = 1</strong> 表示开启重用。允许将TIME-WAIT sockets重新用于新的TCP连接，默认为0，表示关闭；<br />
<strong>net.ipv4.tcp_tw_recycle = 1</strong> 表示开启TCP连接中TIME-WAIT sockets的快速回收，默认为0，表示关闭。<br />
<strong>net.ipv4.tcp_fin_timeout</strong> 修改系統默认的 TIMEOUT 时间</p>
<p>下面附上TIME_WAIT状态的意义：</p>
<p>客户端与服务器端建立TCP/IP连接后关闭SOCKET后，服务器端连接的端口<br />
状态为TIME_WAIT</p>
<p>是不是所有执行主动关闭的socket都会进入TIME_WAIT状态呢？<br />
有没有什么情况使主动关闭的socket直接进入CLOSED状态呢？</p>
<p>主动关闭的一方在发送最后一个 ack 后<br />
就会进入 TIME_WAIT 状态 停留2MSL（max segment lifetime）时间<br />
这个是TCP/IP必不可少的，也就是“解决”不了的。</p>
<p>也就是TCP/IP设计者本来是这么设计的<br />
主要有两个原因<br />
1。防止上一次连接中的包，迷路后重新出现，影响新连接<br />
（经过2MSL，上一次连接中所有的重复包都会消失）<br />
2。可靠的关闭TCP连接<br />
在主动关闭方发送的最后一个 ack(fin) ，有可能丢失，这时被动方会重新发<br />
fin, 如果这时主动方处于 CLOSED 状态 ，就会响应 rst 而不是 ack。所以<br />
主动方要处于 TIME_WAIT 状态，而不能是 CLOSED 。</p>
<p>TIME_WAIT 并不会占用很大资源的，除非受到攻击。</p>
<p>还有，如果一方 send 或 recv 超时，就会直接进入 CLOSED 状态</p>
<p>继续阅读:<br />
<a href="http://blog.s135.com/read.php/269.htm">查看Apache并发请求数及其TCP连接状态</a><br />
<a href="http://www.pgsqldb.org/mwiki/index.php/Linux_%E5%8F%8D_DDOS%E7%9A%84%E5%87%A0%E4%B8%AA%E8%AE%BE%E7%BD%AE">Linux 反 DDOS的几个设置</a>
<p>-- EOF --</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li>2008-03-18 -- <a href="http://www.lsproc.com/blog/configure_lamp/" title="lamp 相关配置 [Debian]">lamp 相关配置 [Debian]</a> (2)</li><li>2010-01-15 -- <a href="http://www.lsproc.com/blog/bash_if_parameters/" title="bash if条件判断参数">bash if条件判断参数</a> (0)</li><li>2010-01-09 -- <a href="http://www.lsproc.com/blog/linux_timeline/" title="linux timeline">linux timeline</a> (2)</li><li>2008-12-16 -- <a href="http://www.lsproc.com/blog/linux_webserver_cmd/" title="Webserver 维护常用命令">Webserver 维护常用命令</a> (9)</li><li>2008-11-10 -- <a href="http://www.lsproc.com/blog/useful_linux_command/" title="一些 linux 命令">一些 linux 命令</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.lsproc.com/blog/close_timewait_connection/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Apache 2.x 基于主机名的虚拟主机</title>
		<link>http://www.lsproc.com/blog/apache2x_name_based_virtual_hosting/</link>
		<comments>http://www.lsproc.com/blog/apache2x_name_based_virtual_hosting/#comments</comments>
		<pubDate>Mon, 10 Dec 2007 14:59:28 +0000</pubDate>
		<dc:creator>lostsnow</dc:creator>
				<category><![CDATA[Linux&Webserver]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[虚拟主机]]></category>

		<guid isPermaLink="false">http://www.lostk.com/blog/apache2x_name_based_virtual_hosting/</guid>
		<description><![CDATA[转载时请标明文章原始出处和作者信息, 作者: lostsnow.http://www.lsproc.com/blog/apache2x_name_based_virtual_hosting/
NameVirtualHost *:80

&#60;VirtualHost *:80&#62;
ServerName a.lostk.com
DocumentRoot e:/webserver/htdocs/a
ErrorLog e:/webserver/apache/logs/a.lost-error.log
CustomLog e:/webserver/apache/logs/a.lost-access.log common
    &#60;Directory &#34;e:/webserver/htdocs/a&#34;&#62;
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
   [...]]]></description>
			<content:encoded><![CDATA[<p>转载时请标明文章原始出处和作者信息, 作者: <a href="http://www.lsproc.com/blog/">lostsnow</a>.<br /><a href="http://www.lsproc.com/blog/apache2x_name_based_virtual_hosting/">http://www.lsproc.com/blog/apache2x_name_based_virtual_hosting/</a></p>
<pre class="brush: text">NameVirtualHost *:80

&lt;VirtualHost *:80&gt;
ServerName a.lostk.com
DocumentRoot e:/webserver/htdocs/a
ErrorLog e:/webserver/apache/logs/a.lost-error.log
CustomLog e:/webserver/apache/logs/a.lost-access.log common
    &lt;Directory &quot;e:/webserver/htdocs/a&quot;&gt;
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    &lt;/Directory&gt;
&lt;/VirtualHost&gt;

&lt;VirtualHost *:80&gt;
ServerName b.lostk.com
DocumentRoot e:/webserver/htdocs/b
ErrorLog e:/webserver/apache/logs/b.lost-error.log
CustomLog e:/webserver/apache/logs/b.lost-access.log common
    &lt;Directory &quot;e:/webserver/htdocs/b&quot;&gt;
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    &lt;/Directory&gt;
&lt;/VirtualHost&gt;</pre>
<p>-- EOF --</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li>2008-03-21 -- <a href="http://www.lsproc.com/blog/useful_apache_urlrewrite/" title="一些有用apache重写规则">一些有用apache重写规则</a> (0)</li><li>2008-03-18 -- <a href="http://www.lsproc.com/blog/configure_lamp/" title="lamp 相关配置 [Debian]">lamp 相关配置 [Debian]</a> (2)</li><li>2008-03-05 -- <a href="http://www.lsproc.com/blog/htaccess_error_on_apache/" title="apache下htaccess的Invalid command &#8216;AuthUserFile&#8217;错误">apache下htaccess的Invalid command &#8216;AuthUserFile&#8217;错误</a> (0)</li><li>2008-03-01 -- <a href="http://www.lsproc.com/blog/close_timewait_connection/" title="如何关闭time_wait连接">如何关闭time_wait连接</a> (4)</li><li>2007-06-02 -- <a href="http://www.lsproc.com/blog/port_443_used_by_qq/" title="QQ居然占用443端口">QQ居然占用443端口</a> (9)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.lsproc.com/blog/apache2x_name_based_virtual_hosting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>QQ居然占用443端口</title>
		<link>http://www.lsproc.com/blog/port_443_used_by_qq/</link>
		<comments>http://www.lsproc.com/blog/port_443_used_by_qq/#comments</comments>
		<pubDate>Sat, 02 Jun 2007 02:35:44 +0000</pubDate>
		<dc:creator>lostsnow</dc:creator>
				<category><![CDATA[Linux&Webserver]]></category>
		<category><![CDATA[443]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[QQ]]></category>
		<category><![CDATA[端口]]></category>

		<guid isPermaLink="false">http://www.lostk.com/blog/technology/port_443_used_by_qq/</guid>
		<description><![CDATA[转载时请标明文章原始出处和作者信息, 作者: lostsnow.http://www.lsproc.com/blog/port_443_used_by_qq/
早上突然发现本机测试的 apache 突然无法启动了，首先想到的是配置错误，可是一直也没有动过配置文件，后来就发现443端口被qq占用了。
netstat -ano
说明
a：显示所有连接和监听的端口
n：用ip地址的形式显示地址和端口
o：显示和连接想关的进程id。
用这个方法查出占用端口的进程id
linux系统中，使用
netstat -anp
不过不知道为什么qq会占用443端口，后来qq关了再开再也没出现端口占用情况，google 了一下发现原来也有人出现这种情况：这里还有这里。有知道的能否告知一下。
-- EOF --
Related Posts2008-03-21 -- 一些有用apache重写规则 (0)2008-03-18 -- lamp 相关配置 [Debian] (2)2008-03-05 -- apache下htaccess的Invalid command &#8216;AuthUserFile&#8217;错误 (0)2008-03-01 -- 如何关闭time_wait连接 (4)2007-12-10 -- Apache 2.x 基于主机名的虚拟主机 (0)]]></description>
			<content:encoded><![CDATA[<p>转载时请标明文章原始出处和作者信息, 作者: <a href="http://www.lsproc.com/blog/">lostsnow</a>.<br /><a href="http://www.lsproc.com/blog/port_443_used_by_qq/">http://www.lsproc.com/blog/port_443_used_by_qq/</a></p>
<p>早上突然发现本机测试的 apache 突然无法启动了，首先想到的是配置错误，可是一直也没有动过配置文件，后来就发现443端口被qq占用了。</p>
<blockquote><p>netstat -ano<br />
说明<br />
a：显示所有连接和监听的端口<br />
n：用ip地址的形式显示地址和端口<br />
o：显示和连接想关的进程id。<br />
用这个方法查出占用端口的进程id<br />
linux系统中，使用<br />
netstat -anp</p></blockquote>
<p>不过不知道为什么qq会占用443端口，后来qq关了再开再也没出现端口占用情况，google 了一下发现原来也有人出现这种情况：<a href="http://hi.baidu.com/xiguaboy/blog/item/aadb972bb43fbffae6cd409f.html">这里</a>还有<a href="http://www.juyimeng.com/%e7%94%a8netstat%e5%92%8c%e4%bb%bb%e5%8a%a1%e7%ae%a1%e7%90%86%e5%99%a8%e6%9f%a5%e6%89%be%e5%8d%a0%e7%94%a8%e7%ab%af%e5%8f%a3%e7%9a%84%e8%bf%9b%e7%a8%8b.html">这里</a>。有知道的能否告知一下。
<p>-- EOF --</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li>2008-03-21 -- <a href="http://www.lsproc.com/blog/useful_apache_urlrewrite/" title="一些有用apache重写规则">一些有用apache重写规则</a> (0)</li><li>2008-03-18 -- <a href="http://www.lsproc.com/blog/configure_lamp/" title="lamp 相关配置 [Debian]">lamp 相关配置 [Debian]</a> (2)</li><li>2008-03-05 -- <a href="http://www.lsproc.com/blog/htaccess_error_on_apache/" title="apache下htaccess的Invalid command &#8216;AuthUserFile&#8217;错误">apache下htaccess的Invalid command &#8216;AuthUserFile&#8217;错误</a> (0)</li><li>2008-03-01 -- <a href="http://www.lsproc.com/blog/close_timewait_connection/" title="如何关闭time_wait连接">如何关闭time_wait连接</a> (4)</li><li>2007-12-10 -- <a href="http://www.lsproc.com/blog/apache2x_name_based_virtual_hosting/" title="Apache 2.x 基于主机名的虚拟主机">Apache 2.x 基于主机名的虚拟主机</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.lsproc.com/blog/port_443_used_by_qq/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>重装系统是件麻烦的事</title>
		<link>http://www.lsproc.com/blog/trouble-with-rebuild-system/</link>
		<comments>http://www.lsproc.com/blog/trouble-with-rebuild-system/#comments</comments>
		<pubDate>Tue, 22 Aug 2006 01:19:40 +0000</pubDate>
		<dc:creator>lostsnow</dc:creator>
				<category><![CDATA[Memory&Notes]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[操作系统]]></category>
		<category><![CDATA[重装]]></category>

		<guid isPermaLink="false">http://www.lostk.com/blog/words/trouble-with-rebuild-system/</guid>
		<description><![CDATA[转载时请标明文章原始出处和作者信息, 作者: lostsnow.http://www.lsproc.com/blog/trouble-with-rebuild-system/
昨天终于把单位用的机器重装了，为了玩玩 babel 开始装 php5.1.5 ， mysql5.0.24 ， 去下apache 发现 2.2.3 已经出来了，于是想尝鲜，没想到惹来一大堆麻烦#83


开启 Apache Mod_rewrite
apache 2.2.x + PHP5.1.x 不能运行的解决办法.
apache2.2装完后更改DocumentRoot出现403错误原因
关于PHP5.1下 php文件显示空白问题


弄完我都快能做个Q&#038;A了#76
-- EOF --
Related Posts2008-03-18 -- lamp 相关配置 [Debian] (2)2007-09-07 -- PHP 和 Mysql 学习笔记（四） (0)2007-06-22 -- PHP 和 Mysql 学习笔记（二） (0)2010-05-21 -- Nginx/PHP 文件类型错误解析漏洞：fix_pathinfo (2)2010-04-12 -- nginx userid 模块客户端 cookie 解码 (0)]]></description>
			<content:encoded><![CDATA[<p>转载时请标明文章原始出处和作者信息, 作者: <a href="http://www.lsproc.com/blog/">lostsnow</a>.<br /><a href="http://www.lsproc.com/blog/trouble-with-rebuild-system/">http://www.lsproc.com/blog/trouble-with-rebuild-system/</a></p>
<p>昨天终于把单位用的机器重装了，为了玩玩 <a href="http://www.v2ex.com/go/babel">babel</a> 开始装 <a href="http://www.php.net/downloads.php#v5">php5.1.5</a> ， <a href="http://dev.mysql.com/downloads/mysql/5.0.html">mysql5.0.24</a> ， 去下<a href="http://apache.org/">apache</a> 发现 <a href="http://mirror.vmmatrix.net/apache/httpd/binaries/win32/">2.2.3</a> 已经出来了，于是想尝鲜，没想到惹来一大堆麻烦#83</p>
<blockquote>
<ul>
<li><a href="http://www.lostk.com/bbs/thread-529-1-1.html">开启 Apache Mod_rewrite</a></li>
<li><a href="http://www.lostk.com/bbs/thread-530-1-1.html">apache 2.2.x + PHP5.1.x 不能运行的解决办法.</a></li>
<li><a href="http://www.lostk.com/bbs/thread-533-1-1.html">apache2.2装完后更改DocumentRoot出现403错误原因</a></li>
<li><a href="http://www.lostk.com/bbs/thread-534-1-1.html">关于PHP5.1下 php文件显示空白问题</a></li>
</ul>
</blockquote>
<p>弄完我都快能做个Q&#038;A了#76</p>
<p>-- EOF --</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li>2008-03-18 -- <a href="http://www.lsproc.com/blog/configure_lamp/" title="lamp 相关配置 [Debian]">lamp 相关配置 [Debian]</a> (2)</li><li>2007-09-07 -- <a href="http://www.lsproc.com/blog/php_mysql_study_4/" title="PHP 和 Mysql 学习笔记（四）">PHP 和 Mysql 学习笔记（四）</a> (0)</li><li>2007-06-22 -- <a href="http://www.lsproc.com/blog/php_mysql_study_2/" title="PHP 和 Mysql 学习笔记（二）">PHP 和 Mysql 学习笔记（二）</a> (0)</li><li>2010-05-21 -- <a href="http://www.lsproc.com/blog/nginx_php_pathinfo_securit/" title="Nginx/PHP 文件类型错误解析漏洞：fix_pathinfo">Nginx/PHP 文件类型错误解析漏洞：fix_pathinfo</a> (2)</li><li>2010-04-12 -- <a href="http://www.lsproc.com/blog/nginx_userid_decode/" title="nginx userid 模块客户端 cookie 解码">nginx userid 模块客户端 cookie 解码</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.lsproc.com/blog/trouble-with-rebuild-system/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
