<?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>baalchina &#187; Web</title>
	<atom:link href="http://www.baalchina.net/tag/web/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.baalchina.net</link>
	<description>baalchina技术日志</description>
	<lastBuildDate>Mon, 19 Jul 2010 08:30:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Nginx下只针对logging.php进行https处理的重写规则</title>
		<link>http://www.baalchina.net/2008/08/nginx-https-rewrite/</link>
		<comments>http://www.baalchina.net/2008/08/nginx-https-rewrite/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 13:01:57 +0000</pubDate>
		<dc:creator>baalchina</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[https]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[rewrite]]></category>

		<guid isPermaLink="false">http://baalchina.nau.edu.cn/?p=51</guid>
		<description><![CDATA[在https server下加入如下配置：

?View Code PHPif &#40;$uri !~* &#34;/logging.php$&#34;&#41;
&#123;
rewrite ^/&#40;.*&#41;$ http://$host/$1 redirect;
&#125;

在http server下加入如下配置：

?View Code PHPif &#40;$uri ~* &#34;/logging.php$&#34;&#41;
&#123;
rewrite ^/&#40;.*&#41;$ https://$host/$1 redirect;
&#125;

最后结果就是，用户会且只会在访问logging.php的情况下，才会通过https访问。有效地避免了arp欺骗、嗅探等方法盗取账号密码的行为。
感谢nginx作者的帮助。
http://marc.info/?l=nginx&#38;m=121663148102512&#38;w=2
]]></description>
			<content:encoded><![CDATA[<p>在https server下加入如下配置：</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p51code3'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p513"><td class="code" id="p51code3"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$uri</span> <span style="color: #339933;">!</span>~<span style="color: #339933;">*</span> <span style="color: #0000ff;">&quot;/logging.php$&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
rewrite ^<span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">.*</span><span style="color: #009900;">&#41;</span>$ http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//$host/$1 redirect;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>在http server下加入如下配置：</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p51code4'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p514"><td class="code" id="p51code4"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$uri</span> ~<span style="color: #339933;">*</span> <span style="color: #0000ff;">&quot;/logging.php$&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
rewrite ^<span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">.*</span><span style="color: #009900;">&#41;</span>$ https<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//$host/$1 redirect;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>最后结果就是，用户会且只会在访问logging.php的情况下，才会通过https访问。有效地避免了arp欺骗、嗅探等方法盗取账号密码的行为。</p>
<p>感谢nginx作者的帮助。<br />
<a href="http://marc.info/?l=nginx&amp;m=121663148102512&amp;w=2">http://marc.info/?l=nginx&amp;m=121663148102512&amp;w=2</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.baalchina.net/2008/08/nginx-https-rewrite/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CentOS下的PHP安全</title>
		<link>http://www.baalchina.net/2008/08/centos%e4%b8%8b%e7%9a%84php%e5%ae%89%e5%85%a8/</link>
		<comments>http://www.baalchina.net/2008/08/centos%e4%b8%8b%e7%9a%84php%e5%ae%89%e5%85%a8/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 11:50:15 +0000</pubDate>
		<dc:creator>baalchina</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[安全]]></category>

		<guid isPermaLink="false">http://baalchina.nau.edu.cn/?p=30</guid>
		<description><![CDATA[打造安全的CENTOS服务器---php安全
2008-08-05 22:11:13 来源:中国站长站 作者:编辑整理 【大 中 小】 评论：0 条
http://www.chinaz.com/Server/Safe/0P534HR008.html
软件配置：
httpd-2.0.52-28.ent.centos4
php-4.3.9-3.15
1、开启安全模式（做为商业应用的服务器不建议开启）
复制内容到剪贴板
代码:

?View Code BASH#vi /usr/local/Zend/etc/php.ini            (没装ZO时php.ini文件位置为：/etc/php.ini)
&#160;
safe_mode = On

2、锁定PHP程序应用目录
复制内容到剪贴板
代码:

?View Code BASH#vi /etc tpd/conf.d irtualhost.conf

加入

php_admin_value open_basedir /home/*** （***为站点目录）

3、千万不要给不必要的目录给写权限，也就是777权限，根目录保持为711权限，如果不能运行PHP请改为755
4、屏蔽PHP不安全的参数(webshell)
复制内容到剪贴板
代码:

?View Code BASH&#160;
#vi /usr/local/Zend/etc/php.ini           (没装ZO时php.ini文件位置为：/etc/php.ini)
&#160;
disable_functions = system,exec,shell_exec,passthru,popen

以下为我的服务器屏蔽参数：

?View Code PHP&#160;
disable_functions = passthru,exec,shell_exec,system,set_time_limit,ini_alter,dl,
&#160;
pfsockopen,openlog,syslog,readlink,symlink,link,leak,fsockopen,popen,escapeshell
&#160;
cmd,error_log

]]></description>
			<content:encoded><![CDATA[<p>打造安全的CENTOS服务器---php安全<br />
2008-08-05 22:11:13 来源:中国站长站 作者:编辑整理 【大 中 小】 评论：0 条<br />
<a href="http://www.chinaz.com/Server/Safe/0P534HR008.html">http://www.chinaz.com/Server/Safe/0P534HR008.html</a></p>
<p>软件配置：</p>
<p>httpd-2.0.52-28.ent.centos4</p>
<p>php-4.3.9-3.15</p>
<p>1、开启安全模式（做为商业应用的服务器不建议开启）</p>
<p>复制内容到剪贴板</p>
<p>代码:</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p30code9'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p309"><td class="code" id="p30code9"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#vi /usr/local/Zend/etc/php.ini            (没装ZO时php.ini文件位置为：/etc/php.ini)</span>
&nbsp;
safe_mode = On</pre></td></tr></table></div>

<p>2、锁定PHP程序应用目录</p>
<p>复制内容到剪贴板</p>
<p>代码:</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p30code10'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p3010"><td class="code" id="p30code10"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#vi /etc tpd/conf.d irtualhost.conf</span></pre></td></tr></table></div>

<p>加入</p>
<pre>
php_admin_value open_basedir /home/*** （***为站点目录）
</pre>
<p>3、千万不要给不必要的目录给写权限，也就是777权限，根目录保持为711权限，如果不能运行PHP请改为755</p>
<p>4、屏蔽PHP不安全的参数(webshell)</p>
<p>复制内容到剪贴板</p>
<p>代码:</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p30code11'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p3011"><td class="code" id="p30code11"><pre class="bash" style="font-family:monospace;">&nbsp;
<span style="color: #666666; font-style: italic;">#vi /usr/local/Zend/etc/php.ini           (没装ZO时php.ini文件位置为：/etc/php.ini)</span>
&nbsp;
disable_functions = system,<span style="color: #7a0874; font-weight: bold;">exec</span>,shell_exec,passthru,popen</pre></td></tr></table></div>

<p>以下为我的服务器屏蔽参数：</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p30code12'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p3012"><td class="code" id="p30code12"><pre class="php" style="font-family:monospace;">&nbsp;
disable_functions <span style="color: #339933;">=</span> <a href="http://www.php.net/passthru"><span style="color: #990000;">passthru</span></a><span style="color: #339933;">,</span><a href="http://www.php.net/exec"><span style="color: #990000;">exec</span></a><span style="color: #339933;">,</span><a href="http://www.php.net/shell_exec"><span style="color: #990000;">shell_exec</span></a><span style="color: #339933;">,</span><a href="http://www.php.net/system"><span style="color: #990000;">system</span></a><span style="color: #339933;">,</span><a href="http://www.php.net/set_time_limit"><span style="color: #990000;">set_time_limit</span></a><span style="color: #339933;">,</span><a href="http://www.php.net/ini_alter"><span style="color: #990000;">ini_alter</span></a><span style="color: #339933;">,</span><a href="http://www.php.net/dl"><span style="color: #990000;">dl</span></a><span style="color: #339933;">,</span>
&nbsp;
<a href="http://www.php.net/pfsockopen"><span style="color: #990000;">pfsockopen</span></a><span style="color: #339933;">,</span><a href="http://www.php.net/openlog"><span style="color: #990000;">openlog</span></a><span style="color: #339933;">,</span><a href="http://www.php.net/syslog"><span style="color: #990000;">syslog</span></a><span style="color: #339933;">,</span><a href="http://www.php.net/readlink"><span style="color: #990000;">readlink</span></a><span style="color: #339933;">,</span><a href="http://www.php.net/symlink"><span style="color: #990000;">symlink</span></a><span style="color: #339933;">,</span><a href="http://www.php.net/link"><span style="color: #990000;">link</span></a><span style="color: #339933;">,</span>leak<span style="color: #339933;">,</span><a href="http://www.php.net/fsockopen"><span style="color: #990000;">fsockopen</span></a><span style="color: #339933;">,</span><a href="http://www.php.net/popen"><span style="color: #990000;">popen</span></a><span style="color: #339933;">,</span>escapeshell
&nbsp;
cmd<span style="color: #339933;">,</span><a href="http://www.php.net/error_log"><span style="color: #990000;">error_log</span></a></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.baalchina.net/2008/08/centos%e4%b8%8b%e7%9a%84php%e5%ae%89%e5%85%a8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nginx+Apache2+SSL的Web服务器配置</title>
		<link>http://www.baalchina.net/2008/08/nginxapache2%e7%9a%84web%e6%9c%8d%e5%8a%a1%e5%99%a8%e9%85%8d%e7%bd%ae/</link>
		<comments>http://www.baalchina.net/2008/08/nginxapache2%e7%9a%84web%e6%9c%8d%e5%8a%a1%e5%99%a8%e9%85%8d%e7%bd%ae/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 06:51:41 +0000</pubDate>
		<dc:creator>baalchina</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[服务器管理]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://baalchina.nau.edu.cn/?p=25</guid>
		<description><![CDATA[最近一直困扰于Apache2负载过高的问题。CPU始终在70%以上，晚上的高峰直接是页面打开很慢很慢，又到了当初Apache2 MPM模块没有配置好时候的情况了...不过那个时候的CPU不高，还有发挥余地，现在就有点头疼了。
学校是不大可能给你升级服务器的了，于是下决心把Apache2换成了Nginx。
Nginx的介绍不说了，google上很多。就是一个俄罗斯的，大家都认为很牛X的Web Server。比较头疼的就是他的中文文档少之又少。
参照了Discuz!商业区的文章，利用Nginx，将PHP请求转发给Apache2，由后者负责处理。并未采用网上介绍的比较多的FastCGI模式。
1、首先是安装Nginx。我的配置模式如下：

?View Code BASH#./configure \
&#34;--with-http_stub_status_module&#34; \
&#34;--with-http_addition_module&#34; \ 
&#34;--with-http_realip_module &#34; \
&#34;--with-pcre=/usr/src/pcre-7.7/&#34; \
&#34;--with-http_ssl_module&#34; \ 
&#34;--with-openssl=/data/soft/openssl-0.9.8e/&#34; \ 
#make
#make install

需要注意的是那个pcre7.7，Perl Compatible Regular Expressions，在使用Discuz!以及其他程序的Rewrite的时候会用到。
OpenSSL是用于HTTPS的，如果不需要可以不编译。
Pcre以及OpenSSL的目录都是它源代码的目录，而不是它的安装目录。
Stub-status是一个状况模块，可以查看Nginx当前的运行状态，类似于Apache2的ServerStatus。
2、然后是重新编辑Apache2，大部分模块都不需要了，可以在config里面去掉。

?View Code BASH#./configure \
&#34;--prefix=/usr/local/apache2&#34; \ 
&#34;--with-apr=/usr/local/apr&#34; \
&#34;--with-apr-util=/usr/local/apr-util/bin&#34; \

重新编译的话会遇到APR的问题。错误如下：
configure: error: Cannot use an external APR with the bundled APR-utilq，
这个以前遇到过。解决方法如下：
安装apr以及apr-util。

?View Code BASH#cd /usr/local/httpd-2-2-4/srclib/apr 
#./configure --prefix=/usr/local/apr 
#make
#make install

安装APR-util

?View Code BASH#cd srclib/apr-util 
#./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr 
#make
#make install

这些文件在Apache2的源码包里面有。
3、然后是PHP+eAcelerator。
投了个懒，直接把原来Apache下的PHP配置加进来了。

?View Code BASH1
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
#./configure \
&#34;--prefix=/usr/local/php&#34; [...]]]></description>
			<content:encoded><![CDATA[<p>最近一直困扰于Apache2负载过高的问题。CPU始终在70%以上，晚上的高峰直接是页面打开很慢很慢，又到了当初Apache2 MPM模块没有配置好时候的情况了...不过那个时候的CPU不高，还有发挥余地，现在就有点头疼了。</p>
<p>学校是不大可能给你升级服务器的了，于是下决心把Apache2换成了Nginx。</p>
<p>Nginx的介绍不说了，google上很多。就是一个俄罗斯的，大家都认为很牛X的Web Server。比较头疼的就是他的中文文档少之又少。</p>
<p>参照了Discuz!商业区的文章，利用Nginx，将PHP请求转发给Apache2，由后者负责处理。并未采用网上介绍的比较多的FastCGI模式。</p>
<p>1、首先是安装Nginx。我的配置模式如下：</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p25code30'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2530"><td class="code" id="p25code30"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#./configure \</span>
<span style="color: #ff0000;">&quot;--with-http_stub_status_module&quot;</span> \
<span style="color: #ff0000;">&quot;--with-http_addition_module&quot;</span> \ 
<span style="color: #ff0000;">&quot;--with-http_realip_module &quot;</span> \
<span style="color: #ff0000;">&quot;--with-pcre=/usr/src/pcre-7.7/&quot;</span> \
<span style="color: #ff0000;">&quot;--with-http_ssl_module&quot;</span> \ 
<span style="color: #ff0000;">&quot;--with-openssl=/data/soft/openssl-0.9.8e/&quot;</span> \ 
<span style="color: #666666; font-style: italic;">#make</span>
<span style="color: #666666; font-style: italic;">#make install</span></pre></td></tr></table></div>

<p>需要注意的是那个pcre7.7，Perl Compatible Regular Expressions，在使用Discuz!以及其他程序的Rewrite的时候会用到。<br />
OpenSSL是用于HTTPS的，如果不需要可以不编译。<br />
<strong>Pcre以及OpenSSL的目录都是它源代码的目录，而不是它的安装目录。</strong><br />
Stub-status是一个状况模块，可以查看Nginx当前的运行状态，类似于Apache2的ServerStatus。</p>
<p>2、然后是重新编辑Apache2，大部分模块都不需要了，可以在config里面去掉。</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p25code31'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2531"><td class="code" id="p25code31"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#./configure \</span>
<span style="color: #ff0000;">&quot;--prefix=/usr/local/apache2&quot;</span> \ 
<span style="color: #ff0000;">&quot;--with-apr=/usr/local/apr&quot;</span> \
<span style="color: #ff0000;">&quot;--with-apr-util=/usr/local/apr-util/bin&quot;</span> \</pre></td></tr></table></div>

<p>重新编译的话会遇到APR的问题。错误如下：</p>
<p>configure: error: Cannot use an external APR with the bundled APR-utilq，</p>
<p>这个以前遇到过。解决方法如下：</p>
<p>安装apr以及apr-util。</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p25code32'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2532"><td class="code" id="p25code32"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#cd /usr/local/httpd-2-2-4/srclib/apr </span>
<span style="color: #666666; font-style: italic;">#./configure --prefix=/usr/local/apr </span>
<span style="color: #666666; font-style: italic;">#make</span>
<span style="color: #666666; font-style: italic;">#make install</span></pre></td></tr></table></div>

<p>安装APR-util</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p25code33'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2533"><td class="code" id="p25code33"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#cd srclib/apr-util </span>
<span style="color: #666666; font-style: italic;">#./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr </span>
<span style="color: #666666; font-style: italic;">#make</span>
<span style="color: #666666; font-style: italic;">#make install</span></pre></td></tr></table></div>

<p>这些文件在Apache2的源码包里面有。</p>
<p>3、然后是PHP+eAcelerator。</p>
<p>投了个懒，直接把原来Apache下的PHP配置加进来了。</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p25code34'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2534"><td class="line_numbers"><pre>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
</pre></td><td class="code" id="p25code34"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#./configure \</span>
<span style="color: #ff0000;">&quot;--prefix=/usr/local/php&quot;</span> \ 
<span style="color: #ff0000;">&quot;--with-apxs2=/usr/local/apache2/bin/apxs&quot;</span> \ 
<span style="color: #ff0000;">&quot;--with-config-file-path=/etc &quot;</span> \ 
<span style="color: #ff0000;">&quot;--with-mysql=/usr/local/mysql &quot;</span> \ 
<span style="color: #ff0000;">&quot;--with-libxml-dir=/usr/local/libxml2 &quot;</span> \ 
<span style="color: #ff0000;">&quot;--with-gd=/usr/local/gd2 &quot;</span> \ 
<span style="color: #ff0000;">&quot;--enable-gd-native-ttf &quot;</span> \ 
<span style="color: #ff0000;">&quot;--with-jpeg-dir &quot;</span> \ 
<span style="color: #ff0000;">&quot;--with-png-dir &quot;</span> \ 
<span style="color: #ff0000;">&quot;--with-bz2 &quot;</span> \ 
<span style="color: #ff0000;">&quot;--with-freetype-dir &quot;</span> \ 
<span style="color: #ff0000;">&quot;--with-iconv-dir &quot;</span> \ 
<span style="color: #ff0000;">&quot;--with-zlib-dir &quot;</span> \ 
<span style="color: #ff0000;">&quot;--enable-mbstring &quot;</span> \ 
<span style="color: #ff0000;">&quot;--disable-ipv6 &quot;</span> \ 
<span style="color: #ff0000;">&quot;--disable-cgi &quot;</span> \ 
<span style="color: #ff0000;">&quot;--disable-cli &quot;</span> \ 
<span style="color: #ff0000;">&quot;--enable-ftp &quot;</span> \ 
<span style="color: #ff0000;">&quot;--enable-magic-quotes &quot;</span> \ 
<span style="color: #ff0000;">&quot;--with-pear &quot;</span> \ 
<span style="color: #ff0000;">&quot;--enable-sockets &quot;</span> \ 
<span style="color: #ff0000;">&quot;--with-ttf &quot;</span> \ 
<span style="color: #ff0000;">&quot;--enable-gd-native-ttf &quot;</span> \ 
<span style="color: #ff0000;">&quot;--enable-sysvsem &quot;</span> \ 
<span style="color: #ff0000;">&quot;--enable-sysvshm &quot;</span> \ 
<span style="color: #ff0000;">&quot;--with-pcre-regex &quot;</span> \ 
<span style="color: #ff0000;">&quot;--enable-xml&quot;</span> \</pre></td></tr></table></div>

<p>另外根据DZ系统的情况添加了一些乱七八糟的东东。比如什么ftp啥的。</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p25code35'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2535"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p25code35"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#cp php-dist.ini /etc/php.ini</span></pre></td></tr></table></div>

<p>接下来安装eAcelerator.</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p25code36'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2536"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p25code36"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>bbs eaccelerator-0.9.5.3<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># make install</span>
Installing shared extensions:     <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">local</span><span style="color: #000000; font-weight: bold;">/</span>php<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>php<span style="color: #000000; font-weight: bold;">/</span>extensions<span style="color: #000000; font-weight: bold;">/</span>no-debug-non-zts-<span style="color: #000000;">20060613</span><span style="color: #000000; font-weight: bold;">/</span></pre></td></tr></table></div>

<p>注意系统提示。将下面这段修改之后加入到/etc/php.ini的末尾</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p25code37'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2537"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code" id="p25code37"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">extension_dir</span>=<span style="color: #ff0000;">&quot;/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/&quot;</span>
<span style="color: #007800;">extension</span>=<span style="color: #ff0000;">&quot;eaccelerator.so&quot;</span>
eaccelerator.cache_dir=<span style="color: #ff0000;">&quot;/tmp/eaccelerator&quot;</span>
eaccelerator.shm_size=<span style="color: #ff0000;">&quot;64&quot;</span>
eaccelerator.enable=<span style="color: #ff0000;">&quot;1&quot;</span>
eaccelerator.optimizer=<span style="color: #ff0000;">&quot;1&quot;</span>
eaccelerator.check_mtime=<span style="color: #ff0000;">&quot;1&quot;</span>
eaccelerator.debug=<span style="color: #ff0000;">&quot;0&quot;</span>
eaccelerator.filter=<span style="color: #ff0000;">&quot;&quot;</span>
eaccelerator.shm_max=<span style="color: #ff0000;">&quot;0&quot;</span>
eaccelerator.shm_ttl=<span style="color: #ff0000;">&quot;60&quot;</span>
eaccelerator.shm_prune_period=<span style="color: #ff0000;">&quot;60&quot;</span>
eaccelerator.shm_only=<span style="color: #ff0000;">&quot;0&quot;</span>
eaccelerator.compress=<span style="color: #ff0000;">&quot;1&quot;</span>
eaccelerator.compress_level=<span style="color: #ff0000;">&quot;9&quot;</span>
eaccelerator.keys=<span style="color: #ff0000;">&quot;shm_and_disk&quot;</span>
eaccelerator.sessions=<span style="color: #ff0000;">&quot;shm_and_disk&quot;</span>
eaccelerator.content=<span style="color: #ff0000;">&quot;shm_and_disk&quot;</span></pre></td></tr></table></div>

<p>下面是Zend，虽然DZ不再加密了，不过有了总比没有好。很简单，不再多说。</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p25code38'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2538"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p25code38"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#./install.sh</span></pre></td></tr></table></div>

<p>查看php.ini，是否已加载。</p>
<p>4、其他的诸如GD等不再赘述了，很简单。不过要记得在最开始安装。</p>
<p>5、进入Nginx的配置阶段。</p>
<p>Nginx的一些Tips:</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p25code39'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2539"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p25code39"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#/usr/local/nginx/sbin/nginx -t</span></pre></td></tr></table></div>

<p>测试Config文件是否正常。如果不正常会提示你在哪一行出错。</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p25code40'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2540"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p25code40"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#/usr/local/nginx/sbin/nginx</span></pre></td></tr></table></div>

<p>启动Nginx进程。和Apache2不同的是，他没有restart/start/stop这样的脚本。</p>
<p>相对应的，重新启动Nginx则是<br />
首先</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p25code41'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2541"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p25code41"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#ps -ef | grep &quot;nginx: master process&quot; | grep -v &quot;grep&quot; | awk -F ' ' '{print $2}'</span></pre></td></tr></table></div>

<p>显示出来的就是Nginx的主进程的ID号。然后</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p25code42'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2542"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p25code42"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#kill -HUP xxxx</span></pre></td></tr></table></div>

<p>即可</p>
<p>下面是Nginx的Config文件配置部分。他的配置文件只有一个，就是/usr/local/nginx/conf/nginx.conf</p>
<p>Nginx的配置文档有点类似于C语言的{}形式。比如一个典型的虚拟主机配置</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p25code43'); return false;">View Code</a> C</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2543"><td class="line_numbers"><pre>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
</pre></td><td class="code" id="p25code43"><pre class="c" style="font-family:monospace;">server
 <span style="color: #009900;">&#123;</span>
   listen       <span style="color: #0000dd;">80</span><span style="color: #339933;">;</span>
   server_name zone.<span style="color: #202020;">nau</span>.<span style="color: #202020;">edu</span>.<span style="color: #202020;">cn</span><span style="color: #339933;">;</span>
   index index.<span style="color: #202020;">html</span> index.<span style="color: #202020;">htm</span> index.<span style="color: #202020;">php</span><span style="color: #339933;">;</span>
   root <span style="color: #339933;">/</span>data<span style="color: #339933;">/</span>web<span style="color: #339933;">/</span>nauzone<span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #339933;">#Upload Size</span>
   client_max_body_size 6M
&nbsp;
     location <span style="color: #339933;">/</span> 
    <span style="color: #009900;">&#123;</span>
       valid_referers   none  blocked  bbs.<span style="color: #202020;">nau</span>.<span style="color: #202020;">edu</span>.<span style="color: #202020;">cn</span>  <span style="color: #339933;">*</span>.<span style="color: #202020;">nau</span>.<span style="color: #202020;">edu</span>.<span style="color: #202020;">cn</span><span style="color: #339933;">;</span>
       <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>$invalid_referer<span style="color: #009900;">&#41;</span>
       <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">return</span>   <span style="color: #0000dd;">403</span><span style="color: #339933;">;</span>
       <span style="color: #009900;">&#125;</span>
        root   <span style="color: #339933;">/</span>data<span style="color: #339933;">/</span>web<span style="color: #339933;">/</span>nauzone<span style="color: #339933;">;</span>
        index index.<span style="color: #202020;">php</span> index.<span style="color: #202020;">html</span> index.<span style="color: #202020;">htm</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #339933;">#UCHome Rewrite Rule</span>
        rewrite <span style="color: #339933;">^/</span><span style="color: #009900;">&#40;</span>space<span style="color: #339933;">|</span>network<span style="color: #009900;">&#41;</span>\<span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span>.<span style="color: #339933;">+</span><span style="color: #009900;">&#41;</span>\.<span style="color: #202020;">html</span>$ <span style="color: #339933;">/</span>$1.<span style="color: #202020;">php</span><span style="color: #339933;">?</span>rewrite<span style="color: #339933;">=</span>$<span style="color: #0000dd;">2</span> last<span style="color: #339933;">;</span>
        rewrite <span style="color: #339933;">^/</span><span style="color: #009900;">&#40;</span>space<span style="color: #339933;">|</span>network<span style="color: #009900;">&#41;</span>\.<span style="color: #202020;">html</span>$ <span style="color: #339933;">/</span>$1.<span style="color: #202020;">php</span> last<span style="color: #339933;">;</span>
        rewrite <span style="color: #339933;">^/</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #339933;">-</span><span style="color: #0000dd;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#41;</span>$ <span style="color: #339933;">/</span>space.<span style="color: #202020;">php</span><span style="color: #339933;">?</span>uid<span style="color: #339933;">=</span>$<span style="color: #0000dd;">1</span> last<span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #339933;">#Forward PHP Request TO Apache Server</span>
      location ~ \.<span style="color: #202020;">php</span>$ 
     <span style="color: #009900;">&#123;</span>
       proxy_pass   http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//127.0.0.1:81;</span>
       proxy_redirect          off<span style="color: #339933;">;</span>
       proxy_set_header Host $host<span style="color: #339933;">;</span>
       proxy_set_header X<span style="color: #339933;">-</span>Real<span style="color: #339933;">-</span>IP $remote_addr<span style="color: #339933;">;</span>
       proxy_set_header X<span style="color: #339933;">-</span>Forwarded<span style="color: #339933;">-</span><span style="color: #b1b100;">For</span> $proxy_add_x_forwarded_for<span style="color: #339933;">;</span>
      <span style="color: #339933;">#proxy_hide_header Content-Type;</span>
      <span style="color: #009900;">&#125;</span>
 <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>这一段配置是放在http部分的。很简单，也很容易理解。</p>
<p>需要注意的是这部分</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p25code44'); return false;">View Code</a> C</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2544"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code" id="p25code44"><pre class="c" style="font-family:monospace;">  <span style="color: #339933;">#Forward PHP Request TO Apache Server</span>
    location ~ \.<span style="color: #202020;">php</span>$ 
   <span style="color: #009900;">&#123;</span>
     proxy_pass   http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//127.0.0.1:81;</span>
     proxy_redirect          off<span style="color: #339933;">;</span>
     proxy_set_header Host $host<span style="color: #339933;">;</span>
     proxy_set_header X<span style="color: #339933;">-</span>Real<span style="color: #339933;">-</span>IP $remote_addr<span style="color: #339933;">;</span>
     proxy_set_header X<span style="color: #339933;">-</span>Forwarded<span style="color: #339933;">-</span><span style="color: #b1b100;">For</span> $proxy_add_x_forwarded_for<span style="color: #339933;">;</span>
     <span style="color: #339933;">#proxy_hide_header Content-Type;</span>
   <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>作用是将PHP的请求转发给Apache2处理。和DZ商业区的那篇文章区别在于，我将最后一行注释掉了。这一个问题困扰了我一天多。</p>
<p>如果不注释掉的话，结果就是会将Content-type传递给Apache2。</p>
<p>而Discuz!的Ajax功能，用到了/templates/default/header_ajax.htm这个文件，这个文件很奇怪，虽然是.htm，但是在内容里却包含了</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p25code45'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2545"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p25code45"><pre class="php" style="font-family:monospace;"><span style="color: #009900;">&#123;</span><a href="http://www.php.net/eval"><span style="color: #990000;">eval</span></a> <span style="color: #339933;">@</span><a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-type: application/xml; charset=<span style="color: #006699; font-weight: bold;">$charset</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>具体的用意不知道，但是肯定是和这个Content-Type有关的。结果就是传递出错，造成Discuz!所有使用到AJAX的功能均不正常，包括表情、投票贴内容、评分等等。</p>
<p>注释掉这一段即OK。也就是Nginx不会将Content-Type传递给Apache2。</p>
<p>=======================================================================<br />
20080523添加，防盗链配置</p>
<p>在location部分添加以下内容。</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p25code46'); return false;">View Code</a> C</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2546"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p25code46"><pre class="c" style="font-family:monospace;">valid_referers   none  blocked  bbs.<span style="color: #202020;">nau</span>.<span style="color: #202020;">edu</span>.<span style="color: #202020;">cn</span>  <span style="color: #339933;">*</span>.<span style="color: #202020;">nau</span>.<span style="color: #202020;">edu</span>.<span style="color: #202020;">cn</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>$invalid_referer<span style="color: #009900;">&#41;</span> 
   <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span>   <span style="color: #0000dd;">403</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>其中，<em>valid_referers</em>可选参数包括none,blocked,以及server_names。</p>
<p>None就是没有，简单的说就是直接通过下载软件下载文件，没有提供referers.<br />
Blocked就是“一块”主机头，比如我前面的配置，可以通过*来通配符。注意不是“阻塞”的意思哦。<br />
server_names就是简单的一个主机了。</p>
<p>我上面的结果就是（可以通过Bitcomet测试），如果不输入主机头、或者指定Referer,下载均可成功。而如果是错误的主机头，就会报403错误。</p>
<p>另外location可以只针对特定文件，比如图片。</p>
<p>参考文章：<br />
官方Wiki:<br />
<a href="http://wiki.codemongers.com/NginxHttpRefererModule?highlight=%28blocked%29%7C%28server_names%29">http://wiki.codemongers.com/NginxHttpRefererModule?highlight=%28blocked%29%7C%28server_names%29</a></p>
<p>=======================================================================<br />
20080526添加日志部分</p>
<p>现在需要做的就是把它和Awstats结合起来。</p>
<p>首先配置日志。官方文档提到一个log_format格式，如下：</p>
<p>log_format  combined  '$remote_addr - $remote_user [$time_local] '<br />
                      '"$request" $status $body_bytes_sent '<br />
                      '"$http_referer" "$http_user_agent"';<br />
但是实际上我把它添加到http{}部分的时候不停地报错。<br />
2008/05/26 18:45:16 [emerg] 19875#0: "log_format" directive duplicate "log_format" name in /usr/local/nginx/conf/nginx.conf:26</p>
<p>实际上原因就是因为，“The "combined" log_format is predefined in sources, you do not need to define it.”作者回答我的...汗。</p>
<p>http://wiki.codemongers.com/NginxHttpLogModule</p>
<p>接下来设定每个虚拟主机的配置。</p>
<p>access_log /data/logs/nginx/bbs.access.log;</p>
<p>注意由于nginx不支持管道，所以无法使用cronolog轮询了。也好，避免2g死机问题。我们会使用脚本来实现这个功能。</p>
<p>=======================================================================</p>
<p>20080619添加日志部分</p>
<p>编辑nginx配置文件的时候，可以使用UltraEDIT，然后高亮，选择php，效果会好很多。</p>
<p>=======================================================================</p>
<p>其他功能不多说了，具体可以参照nginx的文档。</p>
<p>参考网站：</p>
<p>1、Nginx官方网站Wiki<br />
http://wiki.codemongers.com/Main</p>
<p>2、bskzq，关于大型论坛系统环境搭建的讨论--理想论坛的终极解决方案<br />
http://www.discuz.net/viewthread.php?tid=882980&#038;highlight=</p>
<p>3、netseek，利用Nginx替代apache实现高性能的Web环境<br />
http://www.discuz.net/viewthread.php?tid=803925&#038;highlight=nginx</p>
<p>4、张宴，Nginx 0.5.33 + PHP 5.2.5（FastCGI）搭建胜过Apache 10倍的Web服务器（第2版）<br />
http://blog.s135.com/read.php/314.htm</p>
]]></content:encoded>
			<wfw:commentRss>http://www.baalchina.net/2008/08/nginxapache2%e7%9a%84web%e6%9c%8d%e5%8a%a1%e5%99%a8%e9%85%8d%e7%bd%ae/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
