<?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/"
	>

<channel>
	<title>一个程序猿 &#187; nginx</title>
	<atom:link href="http://www.sunboyu.cn/tag/nginx/feed" rel="self" type="application/rss+xml" />
	<link>http://www.sunboyu.cn</link>
	<description>时光不会倒流,脚步总要前进</description>
	<pubDate>Tue, 31 Jan 2012 10:50:34 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>使用awstats对nginx的日志进行分析</title>
		<link>http://www.sunboyu.cn/2010/12/10/%e4%bd%bf%e7%94%a8awstats%e5%af%b9nginx%e7%9a%84%e6%97%a5%e5%bf%97%e8%bf%9b%e8%a1%8c%e5%88%86%e6%9e%90.shtml</link>
		<comments>http://www.sunboyu.cn/2010/12/10/%e4%bd%bf%e7%94%a8awstats%e5%af%b9nginx%e7%9a%84%e6%97%a5%e5%bf%97%e8%bf%9b%e8%a1%8c%e5%88%86%e6%9e%90.shtml#comments</comments>
		<pubDate>Fri, 10 Dec 2010 08:13:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[LINUX]]></category>

		<category><![CDATA[awstats]]></category>

		<category><![CDATA[linux]]></category>

		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://www.sunboyu.cn/?p=1326</guid>
		<description><![CDATA[抛弃apache很长时间了，一直在用nginx，基于第三方的统计系统很多，故很久没有分析过web服务器的日志。最近日志突然暴增，从站长统计无法看出具体暴增的原因，故配置awstats进行分析。
awstats在nginx上运行，这个配置我没做过，所以，我依然使用apache作为awstats的服务器使用。只不过换一个端口而已。
apache配置：安装请看之前的日志，配置文件增加一行配置，具体为
&#60;directory &#34;/opt/httpd-2.2.9/cgi-bin&#34;&#62;
&#160;&#160; &#160;AddHandler cgi-script .pl .cgi&#160; #这行即可
&#160;&#160; &#160;AllowOverride None
&#160;&#160; &#160;Options None
&#160;&#160; &#160;Order allow,deny
&#160;&#160; &#160;Allow from all
&#60;/directory&#62;
配置好，基本就可以启动了。注意端口号，别跟nginx重复了。
下载awstats：http://downloads.sourceforge.net/project/awstats/AWStats/7.0/awstats-7.0.tar.gz?r=http%3A%2F%2Fawstats.sourceforge.net%2F&#038;ts=1291968393&#038;use_mirror=cdnetworks-kr-1
解压后，找到 cgi-bin classes css icon js 这几个文件夹。其中cgi-bin里的文件放到apache的 cgi-bin目录下，其他放到apache的网站根目录。
然后访问 hostname:8080/cgi-bin/awstats.pl 看是不是有结果。
配置站点：
复制 cgi-bin目录下 awstats.model.conf 文件 为 awstats.hostname.conf
修改如下几个关键点
LogFile=&#34;/home/www/log/www.google.com.log&#34; #nginx的日志
SiteDomain=&#34;www.google.com&#34;
HostAliases=&#34;localhost google.com 127.0.0.1 REGEX[myserver\.com$]&#34;
配置完这些， 基本就可以使用了。
另外，还要生成报表：命令为
/opt/httpd-2.2.9/cgi-bin/awstats.pl -update -config=hostname                为了方便，可以加到crontab里。到这里就配置完了。
]]></description>
			<content:encoded><![CDATA[<p>抛弃apache很长时间了，一直在用nginx，基于第三方的统计系统很多，故很久没有分析过web服务器的日志。最近日志突然暴增，从站长统计无法看出具体暴增的原因，故配置awstats进行分析。</p>
<p>awstats在nginx上运行，这个配置我没做过，所以，我依然使用apache作为awstats的服务器使用。只不过换一个端口而已。</p>
<p>apache配置：安装请看之前的日志，配置文件增加一行配置，具体为</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">&lt;directory &quot;/opt/httpd-2.2.9/cgi-bin&quot;&gt;</li>
<li>&nbsp;&nbsp; &nbsp;AddHandler cgi-script .pl .cgi&nbsp; #这行即可</li>
<li>&nbsp;&nbsp; &nbsp;AllowOverride None</li>
<li>&nbsp;&nbsp; &nbsp;Options None</li>
<li>&nbsp;&nbsp; &nbsp;Order allow,deny</li>
<li>&nbsp;&nbsp; &nbsp;Allow from all</li>
<li>&lt;/directory&gt;</li></ol></div>
<p>配置好，基本就可以启动了。注意端口号，别跟nginx重复了。</p>
<p>下载awstats：http://downloads.sourceforge.net/project/awstats/AWStats/7.0/awstats-7.0.tar.gz?r=http%3A%2F%2Fawstats.sourceforge.net%2F&#038;ts=1291968393&#038;use_mirror=cdnetworks-kr-1</p>
<p>解压后，找到 cgi-bin classes css icon js 这几个文件夹。其中cgi-bin里的文件放到apache的 cgi-bin目录下，其他放到apache的网站根目录。</p>
<p>然后访问 hostname:8080/cgi-bin/awstats.pl 看是不是有结果。</p>
<p>配置站点：</p>
<p>复制 cgi-bin目录下 awstats.model.conf 文件 为 awstats.hostname.conf</p>
<p>修改如下几个关键点</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">LogFile=&quot;/home/www/log/www.google.com.log&quot; #nginx的日志</li>
<li>SiteDomain=&quot;www.google.com&quot;</li>
<li>HostAliases=&quot;localhost google.com 127.0.0.1 REGEX[myserver\.com$]&quot;</li></ol></div>
<p>配置完这些， 基本就可以使用了。</p>
<p>另外，还要生成报表：命令为</p>
<p>/opt/httpd-2.2.9/cgi-bin/awstats.pl -update -config=hostname                为了方便，可以加到crontab里。到这里就配置完了。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sunboyu.cn/2010/12/10/%e4%bd%bf%e7%94%a8awstats%e5%af%b9nginx%e7%9a%84%e6%97%a5%e5%bf%97%e8%bf%9b%e8%a1%8c%e5%88%86%e6%9e%90.shtml/feed</wfw:commentRss>
		</item>
		<item>
		<title>在nginx下配置自动虚拟主机</title>
		<link>http://www.sunboyu.cn/2010/01/09/%e5%9c%a8nginx%e4%b8%8b%e9%85%8d%e7%bd%ae%e8%87%aa%e5%8a%a8%e8%99%9a%e6%8b%9f%e4%b8%bb%e6%9c%ba.shtml</link>
		<comments>http://www.sunboyu.cn/2010/01/09/%e5%9c%a8nginx%e4%b8%8b%e9%85%8d%e7%bd%ae%e8%87%aa%e5%8a%a8%e8%99%9a%e6%8b%9f%e4%b8%bb%e6%9c%ba.shtml#comments</comments>
		<pubDate>Fri, 08 Jan 2010 16:33:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[LINUX]]></category>

		<category><![CDATA[原创技术]]></category>

		<category><![CDATA[nginx]]></category>

		<category><![CDATA[虚拟主机]]></category>

		<guid isPermaLink="false">http://www.sunboyu.cn/?p=1143</guid>
		<description><![CDATA[以前用apache，很多虚拟主机的时候，用 mod_vhost_alias 模块去解决。nginx似乎没有这样的功能。
原来为了做这个功能，我用python写了一堆脚本，去自动管理nginx的配置文件，结果还是不理想。频繁重写配置文件，频繁重启，总会出现点问题。
在nginx的0.8.*下，发现了这样的功能：http://wiki.nginx.org/NginxHttpCoreModule

Since nginx 0.8.25 named captures can be used in server_name:
server {
  server_name   ~^(www\.)?(?.+)$;
  location / {
    root  /sites/$domain;
  }
}

大喜，于是乎做出如下配置，实现了nginx下自动虚拟主机的功能：
server {
&#160;&#160; &#160; listen&#160; &#160; &#160; &#160;80;
&#160;&#160; &#160; server_name&#160; ~^(?P&#60;domainname&#62;.+)\.autovhost\.sunboyu\.cn$;
&#160;&#160; &#160; location / {
&#160;&#160; &#160; &#160; &#160; #autoindex&#160; on;
&#160;&#160; &#160; &#160; &#160; root&#160; &#160;/home/vhost/$domainname;
&#160;&#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>以前用apache，很多虚拟主机的时候，用 mod_vhost_alias 模块去解决。nginx似乎没有这样的功能。</p>
<p>原来为了做这个功能，我用python写了一堆脚本，去自动管理nginx的配置文件，结果还是不理想。频繁重写配置文件，频繁重启，总会出现点问题。</p>
<p>在nginx的0.8.*下，发现了这样的功能：http://wiki.nginx.org/NginxHttpCoreModule</p>
<blockquote><p>
Since nginx 0.8.25 named captures can be used in server_name:<br />
server {<br />
  server_name   ~^(www\.)?(?<domain>.+)$;<br />
  location / {<br />
    root  /sites/$domain;<br />
  }<br />
}<br />
</domain></p></blockquote>
<p>大喜，于是乎做出如下配置，实现了nginx下自动虚拟主机的功能：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">server {</li>
<li>&nbsp;&nbsp; &nbsp; listen&nbsp; &nbsp; &nbsp; &nbsp;80;</li>
<li>&nbsp;&nbsp; &nbsp; server_name&nbsp; ~^(?P&lt;domainname&gt;.+)\.autovhost\.sunboyu\.cn$;</li>
<li>&nbsp;&nbsp; &nbsp; location / {</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; #autoindex&nbsp; on;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; root&nbsp; &nbsp;/home/vhost/$domainname;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; index&nbsp; index.html index.htm;</li>
<li>&nbsp;&nbsp; &nbsp; }</li>
<li>&nbsp;&nbsp; &nbsp; access_log /home/autovhost.sunboyu.cn.log main;</li>
<li>}</li>
<li>&lt;/domainname&gt;</li></ol></div>
<p>测试通过。</p>
<p>我的开源虚拟主机管理系统nginx版本指日可待。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sunboyu.cn/2010/01/09/%e5%9c%a8nginx%e4%b8%8b%e9%85%8d%e7%bd%ae%e8%87%aa%e5%8a%a8%e8%99%9a%e6%8b%9f%e4%b8%bb%e6%9c%ba.shtml/feed</wfw:commentRss>
		</item>
		<item>
		<title>nginx做反向代理的配置</title>
		<link>http://www.sunboyu.cn/2009/12/16/nginx%e5%81%9a%e5%8f%8d%e5%90%91%e4%bb%a3%e7%90%86%e7%9a%84%e9%85%8d%e7%bd%ae.shtml</link>
		<comments>http://www.sunboyu.cn/2009/12/16/nginx%e5%81%9a%e5%8f%8d%e5%90%91%e4%bb%a3%e7%90%86%e7%9a%84%e9%85%8d%e7%bd%ae.shtml#comments</comments>
		<pubDate>Wed, 16 Dec 2009 10:39:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[LINUX]]></category>

		<category><![CDATA[nginx]]></category>

		<category><![CDATA[proxy]]></category>

		<category><![CDATA[反向代理]]></category>

		<category><![CDATA[透明代理]]></category>

		<guid isPermaLink="false">http://www.sunboyu.cn/?p=1101</guid>
		<description><![CDATA[感谢铎哥的配置，感谢宴哥解决ssl连接的问题。
server
&#160;{
&#160;&#160; &#160; &#160; &#160;listen&#160; &#160; &#160; 8181;
&#160;&#160; &#160; &#160; &#160;resolver 202.96.64.68;
&#160;&#160; &#160; &#160; &#160;location /
&#160;&#160; &#160; &#160; &#160;{
&#160;&#160; &#160; &#160; &#160; &#160; &#160;proxy_pass http://$http_host$request_uri;
&#160;&#160; &#160; &#160; &#160; &#160; &#160;proxy_redirect&#160; &#160; &#160; &#160; &#160; off;
&#160;&#160; &#160; &#160; &#160; &#160; &#160;proxy_set_header&#160; &#160; &#160; &#160; Host&#160; &#160; &#160; &#160; &#160; &#160; $host;
&#160;&#160; &#160; &#160; &#160; &#160; &#160;proxy_set_header&#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>感谢铎哥的配置，感谢宴哥解决ssl连接的问题。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">server</li>
<li>&nbsp;{</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;listen&nbsp; &nbsp; &nbsp; 8181;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;resolver 202.96.64.68;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;location /</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;proxy_pass http://$http_host$request_uri;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;proxy_redirect&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; off;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;proxy_set_header&nbsp; &nbsp; &nbsp; &nbsp; Host&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $host;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;proxy_set_header&nbsp; &nbsp; &nbsp; &nbsp; X-Real-IP&nbsp; &nbsp; &nbsp; &nbsp;$remote_addr;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;proxy_set_header&nbsp; &nbsp; &nbsp; &nbsp; X-Forwarded-For $proxy_add_x_forwarded_for;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;client_max_body_size&nbsp; &nbsp; 10m;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;client_body_buffer_size 128k;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;proxy_connect_timeout&nbsp; &nbsp;90;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;proxy_send_timeout&nbsp; &nbsp; &nbsp; 90;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;proxy_read_timeout&nbsp; &nbsp; &nbsp; 90;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;proxy_buffers&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;32 4k;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;access_log /home/proxy.log;</li>
<li>&nbsp;}</li></ol></div>
]]></content:encoded>
			<wfw:commentRss>http://www.sunboyu.cn/2009/12/16/nginx%e5%81%9a%e5%8f%8d%e5%90%91%e4%bb%a3%e7%90%86%e7%9a%84%e9%85%8d%e7%bd%ae.shtml/feed</wfw:commentRss>
		</item>
		<item>
		<title>django+nginx的部分配置</title>
		<link>http://www.sunboyu.cn/2009/12/16/djangonginx%e7%9a%84%e9%83%a8%e5%88%86%e9%85%8d%e7%bd%ae.shtml</link>
		<comments>http://www.sunboyu.cn/2009/12/16/djangonginx%e7%9a%84%e9%83%a8%e5%88%86%e9%85%8d%e7%bd%ae.shtml#comments</comments>
		<pubDate>Wed, 16 Dec 2009 03:26:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[LINUX]]></category>

		<category><![CDATA[Python]]></category>

		<category><![CDATA[原创技术]]></category>

		<category><![CDATA[django]]></category>

		<category><![CDATA[nginx]]></category>

		<category><![CDATA[配置]]></category>

		<guid isPermaLink="false">http://www.sunboyu.cn/?p=1097</guid>
		<description><![CDATA[nginx的配置，特别感谢爱词霸的吕同学，发扬了开源共享的精神，大大缩短了我的调试成本。
server {
&#160;&#160; &#160;listen 80;
&#160;&#160; &#160;server_name python.sunboyu.cn;
&#160;&#160; &#160;location / {
&#160;&#160; &#160; &#160; &#160; &#160;fastcgi_pass 127.0.0.1:8000;
&#160;&#160; &#160; &#160; &#160; &#160;fastcgi_buffers&#160; &#160; &#160; 16&#160; 128k;
&#160;&#160; &#160; &#160; &#160; &#160;fastcgi_ignore_client_abort&#160; on;
&#160;&#160; &#160; &#160; &#160; &#160;fastcgi_read_timeout 60;
&#160;
&#160;&#160; &#160; &#160; &#160; &#160;fastcgi_param PATH_INFO $fastcgi_script_name;
&#160;&#160; &#160; &#160; &#160; &#160;fastcgi_param REQUEST_METHOD $request_method;
&#160;&#160; &#160; &#160; &#160; &#160;fastcgi_param QUERY_STRING $query_string;
&#160;&#160; &#160; &#160; &#160; &#160;fastcgi_param CONTENT_TYPE [...]]]></description>
			<content:encoded><![CDATA[<p>nginx的配置，特别感谢<a href='http://www.iciba.com/' target='_blank'>爱词霸</a>的<a href='http://blog.lvscar.info/' target='_blank'>吕同学</a>，发扬了开源共享的精神，大大缩短了我的调试成本。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">server {</li>
<li>&nbsp;&nbsp; &nbsp;listen 80;</li>
<li>&nbsp;&nbsp; &nbsp;server_name python.sunboyu.cn;</li>
<li>&nbsp;&nbsp; &nbsp;location / {</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fastcgi_pass 127.0.0.1:8000;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fastcgi_buffers&nbsp; &nbsp; &nbsp; 16&nbsp; 128k;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fastcgi_ignore_client_abort&nbsp; on;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fastcgi_read_timeout 60;</li>
<li>&nbsp;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fastcgi_param PATH_INFO $fastcgi_script_name;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fastcgi_param REQUEST_METHOD $request_method;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fastcgi_param QUERY_STRING $query_string;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fastcgi_param CONTENT_TYPE $content_type;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fastcgi_param CONTENT_LENGTH $content_length;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fastcgi_param SERVER_PROTOCOL&nbsp; $server_protocol;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fastcgi_param SERVER_PORT&nbsp; &nbsp; &nbsp; $server_port;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fastcgi_param SERVER_NAME&nbsp; $server_name;</li>
<li>&nbsp;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fastcgi_pass_header Authorization;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fastcgi_intercept_errors off;</li>
<li>&nbsp;</li>
<li>&nbsp;&nbsp; &nbsp;}</li>
<li>}</li></ol></div>
<p>同时附上一个额外的文档，nginx变量跟cgi协议的对应关系。<br />
注：在配置中，并不是所有的变量必须加上，而是根据环境选择其中应该有的变量，至于具体加哪些变量，得求助高人了。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">#&nbsp; &nbsp; Fast CGI param reference</li>
<li>#&nbsp; &nbsp; fastcgi_param&nbsp; &nbsp; SCRIPT_FILENAME&nbsp; $document_root$fastcgi_script_name;</li>
<li>#&nbsp; &nbsp; fastcgi_param&nbsp; &nbsp; QUERY_STRING&nbsp; $query_string;</li>
<li>#&nbsp; &nbsp; fastcgi_param&nbsp; &nbsp; REQUEST_METHOD&nbsp; $request_method;</li>
<li>#&nbsp; &nbsp; fastcgi_param&nbsp; &nbsp; CONTENT_TYPE&nbsp; $content_type;</li>
<li>#&nbsp; &nbsp; fastcgi_param&nbsp; &nbsp; CONTENT_LENGTH&nbsp; $content_length;</li>
<li>#&nbsp; &nbsp; fastcgi_param&nbsp; &nbsp; GATEWAY_INTERFACE&nbsp; CGI/1.1;</li>
<li>#&nbsp; &nbsp; fastcgi_param&nbsp; &nbsp; SERVER_SOFTWARE&nbsp; nginx;</li>
<li>#&nbsp; &nbsp; fastcgi_param&nbsp; &nbsp; SCRIPT_NAME&nbsp; $fastcgi_script_name;</li>
<li>#&nbsp; &nbsp; fastcgi_param&nbsp; &nbsp; REQUEST_URI&nbsp; $request_uri;</li>
<li>#&nbsp; &nbsp; fastcgi_param&nbsp; &nbsp; DOCUMENT_URI&nbsp; $document_uri;</li>
<li>#&nbsp; &nbsp; fastcgi_param&nbsp; &nbsp; DOCUMENT_ROOT&nbsp; $document_root;</li>
<li>#&nbsp; &nbsp; fastcgi_param&nbsp; &nbsp; SERVER_PROTOCOL&nbsp; $server_protocol;</li>
<li>#&nbsp; &nbsp; fastcgi_param&nbsp; &nbsp; REMOTE_ADDR&nbsp; $remote_addr;</li>
<li>#&nbsp; &nbsp; fastcgi_param&nbsp; &nbsp; REMOTE_PORT&nbsp; $remote_port;</li>
<li>#&nbsp; &nbsp; fastcgi_param&nbsp; &nbsp; SERVER_ADDR&nbsp; $server_addr;</li>
<li>#&nbsp; &nbsp; fastcgi_param&nbsp; &nbsp; SERVER_PORT&nbsp; $server_port;</li>
<li>#&nbsp; &nbsp; fastcgi_param&nbsp; &nbsp; SERVER_NAME&nbsp; $server_name;</li></ol></div>
]]></content:encoded>
			<wfw:commentRss>http://www.sunboyu.cn/2009/12/16/djangonginx%e7%9a%84%e9%83%a8%e5%88%86%e9%85%8d%e7%bd%ae.shtml/feed</wfw:commentRss>
		</item>
		<item>
		<title>针对尚趣网（vsuch.com）的简单优化</title>
		<link>http://www.sunboyu.cn/2009/06/12/%e9%92%88%e5%af%b9%e5%b0%9a%e8%b6%a3%e7%bd%91%ef%bc%88vsuchcom%ef%bc%89%e7%9a%84%e7%ae%80%e5%8d%95%e4%bc%98%e5%8c%96.shtml</link>
		<comments>http://www.sunboyu.cn/2009/06/12/%e9%92%88%e5%af%b9%e5%b0%9a%e8%b6%a3%e7%bd%91%ef%bc%88vsuchcom%ef%bc%89%e7%9a%84%e7%ae%80%e5%8d%95%e4%bc%98%e5%8c%96.shtml#comments</comments>
		<pubDate>Fri, 12 Jun 2009 07:42:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[技术存档]]></category>

		<category><![CDATA[nginx]]></category>

		<category><![CDATA[vsuch]]></category>

		<category><![CDATA[优化]]></category>

		<guid isPermaLink="false">http://www.sunboyu.cn/?p=782</guid>
		<description><![CDATA[最近，一友找我去优化apache，了解后，是vsuch.com网站的问题。
vsuch网站使用lamp＋windows混合平台（汗），追究历史，原来网站用.net编写，后用php重构了整个网站。
整改前 Mysql运行在linux机器上，php运行在windows平台上，中间局域网方式连接。
网站日访问量不小，alexa排名6800，windows平台明显抗不住，经常莫名其妙的问题。（题外话：我最早维护的服务器也是windows，apache在上边很不稳定）
了解后，我感觉一台服务器就足矣，放弃了apache的方案，安装了nginx＋php，数据库依然沿用原来的。
整改后，linux负载稍稍升高，mysql负载不变，http的负载在nginx下并没有表现出多高。顺利完成了迁移。
后公司又开通了cdn服务（有钱），速度有了很明显的提升。
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－
根据其公司目前的技术结构，我提出了很多优化和整改的想法，希望每个创业网站都能走好。
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－
]]></description>
			<content:encoded><![CDATA[<p>最近，一友找我去优化apache，了解后，是vsuch.com网站的问题。</p>
<p>vsuch网站使用lamp＋windows混合平台（汗），追究历史，原来网站用.net编写，后用php重构了整个网站。</p>
<p>整改前 Mysql运行在linux机器上，php运行在windows平台上，中间局域网方式连接。</p>
<p>网站日访问量不小，alexa排名6800，windows平台明显抗不住，经常莫名其妙的问题。（题外话：我最早维护的服务器也是windows，apache在上边很不稳定）</p>
<p>了解后，我感觉一台服务器就足矣，放弃了apache的方案，安装了nginx＋php，数据库依然沿用原来的。</p>
<p>整改后，linux负载稍稍升高，mysql负载不变，http的负载在nginx下并没有表现出多高。顺利完成了迁移。</p>
<p>后公司又开通了cdn服务（有钱），速度有了很明显的提升。</p>
<p>－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－</p>
<p>根据其公司目前的技术结构，我提出了很多优化和整改的想法，希望每个创业网站都能走好。</p>
<p>－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sunboyu.cn/2009/06/12/%e9%92%88%e5%af%b9%e5%b0%9a%e8%b6%a3%e7%bd%91%ef%bc%88vsuchcom%ef%bc%89%e7%9a%84%e7%ae%80%e5%8d%95%e4%bc%98%e5%8c%96.shtml/feed</wfw:commentRss>
		</item>
		<item>
		<title>wordpress在不同webserver下的重写规则和配置</title>
		<link>http://www.sunboyu.cn/2009/04/07/wordpress%e5%9c%a8%e4%b8%8d%e5%90%8cwebserver%e4%b8%8b%e7%9a%84%e9%87%8d%e5%86%99%e8%a7%84%e5%88%99%e5%92%8c%e9%85%8d%e7%bd%ae.shtml</link>
		<comments>http://www.sunboyu.cn/2009/04/07/wordpress%e5%9c%a8%e4%b8%8d%e5%90%8cwebserver%e4%b8%8b%e7%9a%84%e9%87%8d%e5%86%99%e8%a7%84%e5%88%99%e5%92%8c%e9%85%8d%e7%bd%ae.shtml#comments</comments>
		<pubDate>Tue, 07 Apr 2009 13:22:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[其他]]></category>

		<category><![CDATA[apache]]></category>

		<category><![CDATA[nginx]]></category>

		<category><![CDATA[wordpress]]></category>

		<category><![CDATA[重写]]></category>

		<guid isPermaLink="false">http://www.sunboyu.cn/?p=644</guid>
		<description><![CDATA[apache下
#.htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
#httpd.conf
Options ExecCGI FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
nginx下
#nginx.conf
location / {
&#160;&#160; &#160; &#160; &#160;if (!-f $request_filename){
&#160;&#160; &#160; &#160; &#160; &#160; &#160;rewrite (.*) /index.php;
&#160;&#160; &#160; &#160; &#160;}
&#160;&#160; &#160;}
]]></description>
			<content:encoded><![CDATA[<p>apache下</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">#.htaccess</li>
<li>RewriteEngine On</li>
<li>RewriteBase /</li>
<li>RewriteCond %{REQUEST_FILENAME} !-f</li>
<li>RewriteCond %{REQUEST_FILENAME} !-d</li>
<li>RewriteRule . /index.php [L]</li>
<li>#httpd.conf</li>
<li>Options ExecCGI FollowSymLinks</li>
<li>AllowOverride All</li>
<li>Order allow,deny</li>
<li>allow from all</li></ol></div>
<p>nginx下</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">#nginx.conf</li>
<li>location / {</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (!-f $request_filename){</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rewrite (.*) /index.php;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</li>
<li>&nbsp;&nbsp; &nbsp;}</li></ol></div>
]]></content:encoded>
			<wfw:commentRss>http://www.sunboyu.cn/2009/04/07/wordpress%e5%9c%a8%e4%b8%8d%e5%90%8cwebserver%e4%b8%8b%e7%9a%84%e9%87%8d%e5%86%99%e8%a7%84%e5%88%99%e5%92%8c%e9%85%8d%e7%bd%ae.shtml/feed</wfw:commentRss>
		</item>
		<item>
		<title>还是Nginx对抗负载的能力强</title>
		<link>http://www.sunboyu.cn/2009/04/07/%e8%bf%98%e6%98%afnginx%e5%af%b9%e6%8a%97%e8%b4%9f%e8%bd%bd%e7%9a%84%e8%83%bd%e5%8a%9b%e5%bc%ba.shtml</link>
		<comments>http://www.sunboyu.cn/2009/04/07/%e8%bf%98%e6%98%afnginx%e5%af%b9%e6%8a%97%e8%b4%9f%e8%bd%bd%e7%9a%84%e8%83%bd%e5%8a%9b%e5%bc%ba.shtml#comments</comments>
		<pubDate>Tue, 07 Apr 2009 06:45:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[APACHE]]></category>

		<category><![CDATA[LINUX]]></category>

		<category><![CDATA[apache]]></category>

		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://www.sunboyu.cn/?p=640</guid>
		<description><![CDATA[编译了老半天的apache，又做了很多调整和优化，依然抗不住死机，其实负载也不是很大，但内存CPU就是出奇的高，无奈，装上nginx，负载一下子下来了。
顺便提一下，我PC级的服务器。
感谢  http://www.51fit.com/ 友情提供测试数据
计划重新部署apache，调整工作模式。
]]></description>
			<content:encoded><![CDATA[<p>编译了老半天的apache，又做了很多调整和优化，依然抗不住死机，其实负载也不是很大，但内存CPU就是出奇的高，无奈，装上nginx，负载一下子下来了。</p>
<p>顺便提一下，我PC级的服务器。</p>
<p>感谢  http://www.51fit.com/ 友情提供测试数据</p>
<p>计划重新部署apache，调整工作模式。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sunboyu.cn/2009/04/07/%e8%bf%98%e6%98%afnginx%e5%af%b9%e6%8a%97%e8%b4%9f%e8%bd%bd%e7%9a%84%e8%83%bd%e5%8a%9b%e5%bc%ba.shtml/feed</wfw:commentRss>
		</item>
		<item>
		<title>试用webmin来管理nginx</title>
		<link>http://www.sunboyu.cn/2008/05/18/%e8%af%95%e7%94%a8webmin%e6%9d%a5%e7%ae%a1%e7%90%86nginx.shtml</link>
		<comments>http://www.sunboyu.cn/2008/05/18/%e8%af%95%e7%94%a8webmin%e6%9d%a5%e7%ae%a1%e7%90%86nginx.shtml#comments</comments>
		<pubDate>Sun, 18 May 2008 04:30:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[原创技术]]></category>

		<category><![CDATA[nginx]]></category>

		<category><![CDATA[webmin]]></category>

		<guid isPermaLink="false">http://www.sunboyu.cn/?p=10</guid>
		<description><![CDATA[webmin没有nginx的管理模块,可以使用自定义命令来实现
关闭nginx:killall nginx 使用root执行
启动nginx:/usr/local/nginx/sbin/nginx
重启:两个命令连起来就可以,也可以写个简单shell
编辑配置文件:增加编辑文件命令   /usr/local/nginx/conf/**.conf
用着还挺爽的,简单方便
]]></description>
			<content:encoded><![CDATA[<p>webmin没有nginx的管理模块,可以使用自定义命令来实现</p>
<p>关闭nginx:killall nginx 使用root执行</p>
<p>启动nginx:/usr/local/nginx/sbin/nginx</p>
<p>重启:两个命令连起来就可以,也可以写个简单shell</p>
<p>编辑配置文件:增加编辑文件命令   /usr/local/nginx/conf/**.conf</p>
<p>用着还挺爽的,简单方便</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sunboyu.cn/2008/05/18/%e8%af%95%e7%94%a8webmin%e6%9d%a5%e7%ae%a1%e7%90%86nginx.shtml/feed</wfw:commentRss>
		</item>
		<item>
		<title>Nginx下WordPress的重写配置</title>
		<link>http://www.sunboyu.cn/2008/05/18/nginx%e4%b8%8bwordpress%e7%9a%84%e9%87%8d%e5%86%99%e9%85%8d%e7%bd%ae.shtml</link>
		<comments>http://www.sunboyu.cn/2008/05/18/nginx%e4%b8%8bwordpress%e7%9a%84%e9%87%8d%e5%86%99%e9%85%8d%e7%bd%ae.shtml#comments</comments>
		<pubDate>Sun, 18 May 2008 04:30:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[原创技术]]></category>

		<category><![CDATA[nginx]]></category>

		<category><![CDATA[wordpress]]></category>

		<category><![CDATA[重写]]></category>

		<guid isPermaLink="false">http://www.sunboyu.cn/?p=11</guid>
		<description><![CDATA[nginx居然不兼容apache的.htaccess文件,无奈在配置文件中修改.
server
{
listen  80;
location / {
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
server_name sunboyu.cn www.sunboyu.cn *.sunboyu.cn somecode.cn www.somecode.cn *.somecode.cn;
index   index.html index.htm index.php;
root    /***/;
access_log  /***/host.access.log;
}
这样即可
]]></description>
			<content:encoded><![CDATA[<p>nginx居然不兼容apache的.htaccess文件,无奈在配置文件中修改.</p>
<p>server<br />
{<br />
listen  80;</p>
<p>location / {<br />
if (!-f $request_filename){<br />
rewrite (.*) /index.php;<br />
}<br />
}</p>
<p>server_name sunboyu.cn www.sunboyu.cn *.sunboyu.cn somecode.cn www.somecode.cn *.somecode.cn;<br />
index   index.html index.htm index.php;<br />
root    /***/;<br />
access_log  /***/host.access.log;<br />
}</p>
<p>这样即可</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sunboyu.cn/2008/05/18/nginx%e4%b8%8bwordpress%e7%9a%84%e9%87%8d%e5%86%99%e9%85%8d%e7%bd%ae.shtml/feed</wfw:commentRss>
		</item>
		<item>
		<title>centos5安装nginx＋mysql＋php fastcgi模式</title>
		<link>http://www.sunboyu.cn/2008/05/18/centos5%e5%ae%89%e8%a3%85nginx%ef%bc%8bmysql%ef%bc%8bphp-fastcgi%e6%a8%a1%e5%bc%8f.shtml</link>
		<comments>http://www.sunboyu.cn/2008/05/18/centos5%e5%ae%89%e8%a3%85nginx%ef%bc%8bmysql%ef%bc%8bphp-fastcgi%e6%a8%a1%e5%bc%8f.shtml#comments</comments>
		<pubDate>Sun, 18 May 2008 04:20:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[原创技术]]></category>

		<category><![CDATA[centos5]]></category>

		<category><![CDATA[fastcgi]]></category>

		<category><![CDATA[mysql]]></category>

		<category><![CDATA[nginx]]></category>

		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.sunboyu.cn/?p=9</guid>
		<description><![CDATA[原教程 http://blog.s135.com/read.php/314.htm
安装环境：centos5.0 基本系统＋开发工具
安装xml组件
yum install libxml2  libxml2-devel
编译安装 php
./configure  &#8211;enable-fastcgi  &#8211;enable-force-cgi-redirect
make &#38;&#38; make install
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;
[root@localhost php-5.2.5]# make install
Installing PHP SAPI  module:       cgi
Installing PHP CGI binary:        /usr/local/bin/
Installing PHP CLI binary:        /usr/local/bin/
Installing PHP CLI man  [...]]]></description>
			<content:encoded><![CDATA[<div id="blogContainer">原教程 <a onclick="showLinkBubble(this);return false" href="http://blog.s135.com/read.php/314.htm" target="_blank">http://blog.s135.com/read.php/314.htm</a></p>
<p>安装环境：centos5.0 基本系统＋开发工具</p>
<p>安装xml组件<br />
yum install libxml2  libxml2-devel</p>
<p>编译安装 php<br />
./configure  &#8211;enable-fastcgi  &#8211;enable-force-cgi-redirect<br />
make &amp;&amp; make install<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
[root@localhost php-5.2.5]# make install<br />
Installing PHP SAPI  module:       cgi<br />
Installing PHP CGI binary:        /usr/local/bin/<br />
Installing PHP CLI binary:        /usr/local/bin/<br />
Installing PHP CLI man  page:      /usr/local/man/man1/<br />
Installing build environment:      /usr/local/lib/php/build/<br />
Installing header  files:          /usr/local/include/php/<br />
Installing helper programs:        /usr/local/bin/<br />
program: phpize<br />
program: php-config<br />
Installing  man pages:             /usr/local/man/man1/<br />
page: phpize.1<br />
page:  php-config.1<br />
Installing PEAR environment:      /usr/local/lib/php/<br />
[PEAR] Console_Getopt - installed: 1.2.3<br />
[PEAR] Archive_Tar    -  installed: 1.3.2<br />
[PEAR] Structures_Graph- installed: 1.0.2<br />
pear/PEAR can  optionally use package &#8220;pear/XML_RPC&#8221; (version &gt;= 1.4.0)<br />
[PEAR]  PEAR           - installed: 1.6.1<br />
Wrote PEAR system config file at:  /usr/local/etc/pear.conf<br />
You may want to add: /usr/local/lib/php to your  php.ini include_path<br />
Installing PDO  headers:          /usr/local/include/php/ext/pdo/<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
make test</p>
<p>yum安装mysql<br />
yum install mysql mysql-devel mysql-server</p>
<p>复制spawn-fcgi 至 /usr/local/bin/<br />
chmod +x spawn-fcgi</p>
<p>/usr/sbin/groupadd www -g 48<br />
/usr/sbin/useradd -u 48 -g www www<br />
使用spawn-fcgi监听127.0.0.1的10080端口 进程10 用户www<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
[root@localhost bin]# spawn-fcgi -a 127.0.0.1 -p 10080 -C 10 -u www -f  php-cgi<br />
X-Powered-By: PHP/5.2.5<br />
Content-type: text/html<br />
spawn-fcgi.c.211: child exited with: 0, Success<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
[root@localhost bin]# spawn-fcgi -a 127.0.0.1 -p 10080 -C 10 -u www -f  php-cgi<br />
spawn-fcgi.c.190: child spawned successfully: PID: 27936<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
安装pcre<br />
yum install pcre pcre-devel<br />
编译安装 nginx<br />
./configure  &#8211;user=www &#8211;group=www<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Configuration summary<br />
+ threads are not used<br />
+ using system PCRE  library<br />
+ OpenSSL library is not used<br />
+ md5 library is not used<br />
+ sha1 library is not used<br />
+ using system zlib library<br />
nginx  path prefix: &#8220;/usr/local/nginx&#8221;<br />
nginx binary file:  &#8220;/usr/local/nginx/sbin/nginx&#8221;<br />
nginx configuration file:  &#8220;/usr/local/nginx/conf/nginx.conf&#8221;<br />
nginx pid file:  &#8220;/usr/local/nginx/logs/nginx.pid&#8221;<br />
nginx error log file:  &#8220;/usr/local/nginx/logs/error.log&#8221;<br />
nginx http access log file:  &#8220;/usr/local/nginx/logs/access.log&#8221;<br />
nginx http client request body  temporary files: &#8220;/usr/local/nginx/client_body_temp&#8221;<br />
nginx http proxy  temporary files: &#8220;/usr/local/nginx/proxy_temp&#8221;<br />
nginx http fastcgi  temporary files: &#8220;/usr/local/nginx/fastcgi_temp&#8221;<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
make &amp;&amp; make install</p>
<p>touche /usr/local/nginx/conf/fcgi.conf<br />
内容为<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;<br />
fastcgi_param  SERVER_SOFTWARE    nginx;<br />
fastcgi_param  QUERY_STRING       $query_string;<br />
fastcgi_param  REQUEST_METHOD     $request_method;<br />
fastcgi_param  CONTENT_TYPE       $content_type;<br />
fastcgi_param  CONTENT_LENGTH     $content_length;<br />
fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;<br />
fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;<br />
fastcgi_param  REQUEST_URI        $request_uri;<br />
fastcgi_param  DOCUMENT_URI       $document_uri;<br />
fastcgi_param  DOCUMENT_ROOT      $document_root;<br />
fastcgi_param  SERVER_PROTOCOL    $server_protocol;<br />
fastcgi_param  REMOTE_ADDR        $remote_addr;<br />
fastcgi_param  REMOTE_PORT        $remote_port;<br />
fastcgi_param  SERVER_ADDR        $server_addr;<br />
fastcgi_param  SERVER_PORT        $server_port;<br />
fastcgi_param  SERVER_NAME        $server_name;<br />
# PHP only, required if  PHP was built with &#8211;enable-force-cgi-redirect<br />
#fastcgi_param  REDIRECT_STATUS    200;<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
启动 nginx<br />
ulimit -SHn 51200<br />
/usr/local/nginx/sbin/nginx -c  /usr/local/nginx/conf/nginx.conf</p>
<p>配置开机自动启动Nginx + PHP<br />
vi  /etc/rc.local<br />
在末尾增加以下内容：<br />
ulimit -SHn 51200<br />
/usr/local/bin/spawn-fcgi  -a 127.0.0.1 -p 10080 -C 64 -u www -f /usr/local/bin/php-cgi<br />
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf</p>
<p>优化Linux内核参数<br />
vi /etc/sysctl.conf<br />
在末尾增加以下内容：<br />
net.ipv4.tcp_fin_timeout = 30<br />
net.ipv4.tcp_keepalive_time = 300<br />
net.ipv4.tcp_syncookies = 1<br />
net.ipv4.tcp_tw_reuse = 1<br />
net.ipv4.tcp_tw_recycle = 1<br />
net.ipv4.ip_local_port_range = 5000    65000</p>
<p>使配置立即生效：<br />
/sbin/sysctl -p<br />
在不停止Nginx服务的情况下平滑变更Nginx配置<br />
修改/usr/local/nginx/conf/nginx.conf配置文件后，请执行以下命令检查配置文件是否正确：<br />
/usr/local/webserver/nginx/sbin/nginx -t</p>
<p>这时，输入以下命令查看Nginx主进程号：<br />
ps -ef | grep &#8220;nginx: master process&#8221; | grep -v &#8220;grep&#8221; | awk -F &#8216; &#8216; &#8216;{print  $2}&#8217;</p>
<p>至于日常维护，还不太清楚，咱们下次分解</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Nginx的编译参数如下：<br />
[root@localhost]#./configure &#8211;prefix=/usr/local/server/nginx  &#8211;with-openssl=/usr/include \<br />
&#8211;with-pcre=/usr/include/pcre/  &#8211;with-http_stub_status_module &#8211;without-http_memcached_module \<br />
&#8211;without-http_fastcgi_module &#8211;without-http_rewrite_module  &#8211;without-http_map_module \<br />
&#8211;without-http_geo_module  &#8211;without-http_autoindex_module</p>
</div>
<p><img id="paperPicArea1" style="display: none; position: relative;" src="http://imgcache.qq.com/ac/qzone_v4/b.gif" alt="" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sunboyu.cn/2008/05/18/centos5%e5%ae%89%e8%a3%85nginx%ef%bc%8bmysql%ef%bc%8bphp-fastcgi%e6%a8%a1%e5%bc%8f.shtml/feed</wfw:commentRss>
		</item>
	</channel>
</rss>

