<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>影の域 &#187; PHP</title>
	<atom:link href="http://www.zfkun.com/index.php/tag/php/feed" rel="self" type="application/rss+xml" />
	<link>http://www.zfkun.com</link>
	<description>关注web前端,追逐html5脚步,体会code人生</description>
	<lastBuildDate>Tue, 06 Dec 2011 06:45:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>WordPress Rewrite SEO 之404方式折腾笔记</title>
		<link>http://www.zfkun.com/417.html</link>
		<comments>http://www.zfkun.com/417.html#comments</comments>
		<pubDate>Sun, 17 Jul 2011 10:10:57 +0000</pubDate>
		<dc:creator>影之迷惑</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[开发编程]]></category>
		<category><![CDATA[杂七杂八]]></category>
		<category><![CDATA[404]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[rewrite]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.zfkun.com/?p=417</guid>
		<description><![CDATA[    WordPress 是多么强大的Blog（甚至可以说CMS）系统就不用多说了。说到底我把WP只看做一个开发起步的框架而已，更多的性能及功能的挖掘和利用还是需要自己去完成。
    最近折腾 HTML5探索 的SEO时，想起来我的博客依旧还没做过SEO，遂就开始了下面记录中的折腾回忆录。
    空间是虚拟主机（还是WIN + IIS）、无Rewrite、无子域名等等，在诸多的不利因素下，对于强大的WordPress来说，依旧能找到较好的优化方式: 404 Rewrite。SO, 就开始大面积的调整程序 + hack, 终于算完成了现在的Rewrite，真是累死我也。（做了一大堆复杂的兼容工作，历史原因害死人呀！） <a href="http://www.zfkun.com/417.html">阅读全文 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>WordPress 是多么强大的Blog（甚至可以说CMS）系统就不用多说了。说到底我把WP只看做一个开发起步的框架而已，更多的性能及功能的挖掘和利用还是需要自己去完成。<br />
最近折腾 <a title="HTML5探索" href="http://html5.so" target="_blank">HTML5探索</a> 的SEO时，想起来我的博客依旧还没做过SEO，遂就开始了下面记录中的折腾回忆录。<br />
空间是虚拟主机（还是WIN + IIS）、无Rewrite、无子域名等等，在诸多的不利因素下，对于强大的WordPress来说，依旧能找到较好的优化方式: 404 Rewrite<br />
so, 就开始大面积的调整程序 + hack 终于算完成了现在的Rewrite，真是累死我也。（做了一大堆复杂的兼容工作，历史原因害死人呀！）<br />
经过亲身体验，需要提醒下使用 404 Rewrite 前要明确站点是否为新建站点，若是，一切很easy，若不是，就有了我下面的那么多兼容工作要做，悲催！！<br />
正常的对于新建站点（404支持设置为php页面前提），因为站点较新搜索引擎还未开始收录，对外分享也几乎为0。所以需要做的就相对很少，编写好404.php的处理代码，后台做好配置即可。<br />
而有时候（其实就是我现在啦- -）, 站点运行很长时间（几年了），期间经历过无数的配置调整（还有数据丢失，我擦！），对于各种URL已经产生了很多种版本，所以需要做的工作就非常多了。<br />
由于已经过了2天了，具体顺序都不清楚了，这里仅做下回忆录式笔记，以防以后不备之需（身在天朝，谁知哪天又天灾人祸呀！）：</p>
<h3>涉及文件修改列表：</h3>
<blockquote><p>/404.php     /index.php     /blog/index.php</p></blockquote>
<h3>修改回忆录：</h3>
<p>1. /blog/index.php -&gt; /blog/index.php.bak 说白了就是备份<br />
2. 新建 /blog/index.php, 编写一些兼容处理代码:</p>
<pre name="code" class="php">&lt;?php
// zfkun.com to www.zfkun.com
if ( $_SERVER["HTTP_HOST"] === "zfkun.com") {
doRedirect("http://www.");
} else {

// 对所有原有效URL规则做301永久重定向，从而兼容原旧历史路径
$_qu = str_replace('/blog/index.php', '', $_SERVER['REQUEST_URI']);
$_SERVER["REQUEST_URI"] = (empty($_qu) || $_qu == "") ? '/' : $_qu;
doRedirect();
}

function doRedirect($prefix = "http://") {
header( "HTTP/1.1 301 Moved Permanently" );
header("Location: " . $prefix . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] );
}
?&gt;</pre>
<p>3. cp /blog/index.php.bak /index.php, 然后增加兼容处理:</p>
<pre name="code" class="php">&lt;?php
    // zfkun.com to www.zfkun.com
    if ( $_SERVER["HTTP_HOST"] === "zfkun.com" ) {
    header( "HTTP/1.1 301 Moved Permanently" );
    header("Location: " . "http://www." . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] );
    exit;
} else {

	/**
	 * 对 /index.php/archives/* 形式URL做下过滤(历史原因)
	 *    增加对一些特殊路径的兼容纠错,如：
	 *        http://www.zfkun.com/index.php/archives/category/code/javascript
	 *        http://www.zfkun.com/index.php/archives/tag/javascript
	 *        http://www.zfkun.com/index.php/archives/205.html
	 */
	if (strpos($_SERVER['REQUEST_URI'], '/index.php') === 0) {
		$_qu = str_replace( '/archives', '', str_replace('/index.php', '', $_SERVER['REQUEST_URI']) );
		if (!empty($_qu)) {
                    // 修正对 /index.php/archives/239 此类地址解析时忘记补充 .html 造成的BUG
		    if (strpos($_qu, '.html') === false) {
		        // '/205' =&gt; '/205.html'
		         $_qu = preg_replace('/^\/(\d+)/', '$0.html', $_qu);
		    }
		    $_SERVER['PATH_INFO'] = $_SERVER["REQUEST_URI"] = $_qu;
		}
	}
}

// 解决 WordPress的中文路径在WIN + IIS 下的解析错误问题
$_SERVER['PATH_INFO'] = mb_convert_encoding($_SERVER['PATH_INFO'],"UTF-8","GBK");
$_SERVER['REQUEST_URI'] = mb_convert_encoding($_SERVER['REQUEST_URI'], "UTF-8", "GBK");
.....
?&gt;</pre>
<p>4. 新建 /404.php 并设置虚拟主机404错误跳转至它，代码摘要：</p>
<pre name="code" class="php">&lt;?php
/**
 * 重置 $_SERVER['REQUEST_URI'] 为期望访问的值
 * 如：
 *    当前访问  http://www.zfkun.com/date/2010/01 ,
 *    则 404 跳转来的 $_SERVER['QUERY_STRING'] === '404;http://www.zfkun.com:80/date/2010/01'
 */
$_SERVER['REQUEST_URI'] = substr($_SERVER['QUERY_STRING'], strpos($_SERVER['QUERY_STRING'], ':80') + 3);

// blog rule 标志位
$isBlogRule = false;

if (strpos($_SERVER['REQUEST_URI'], '/blog') === 0) {
    $_SERVER['REQUEST_URI'] = substr($_SERVER['REQUEST_URI'], 5);
    $isBlogRule = true;
}

if ($isBlogRule) {
    $_SERVER['REQUEST_URI'] = str_replace('/index.php', '', $_SERVER['REQUEST_URI']);

   /**
    *    /blog/archives/205
    *    /blog/archives/tag/php
    *    /blog/tag/php
    *    /blog/archives/category/code/php
    *    /blog/category/code/php
    */
   if (strpos($_SERVER['REQUEST_URI'], '/archives/') === 0) {
       $_SERVER['REQUEST_URI'] = str_replace('/archives/', '/', $_SERVER['REQUEST_URI']);
   }

    /**
     *  对非静态化后缀的形式进行过滤检测:
     *     可能为: '/blog/205'
     */
    if (strpos($_SERVER['REQUEST_URI'], '.html') === false) {
        // '/205' =&gt; '/205.html'
        $_SERVER['REQUEST_URI'] = preg_replace('/^\/(\d+)/', '$0.html', $_SERVER['REQUEST_URI']);
    }

   /**
    * 检测 queryString 和 hash， 非空需特殊处理
    */
    if (strpos($_SERVER['REQUEST_URI'], '?') === 0 || strpos($_SERVER['REQUEST_URI'], '#') === 0) {
        $_SERVER['REQUEST_URI'] = '/index.php' . $_SERVER['REQUEST_URI'];
        $_SERVER['PATH_INFO'] = '';
    } else {
        $_SERVER['PATH_INFO'] = $_SERVER['REQUEST_URI'];
    }

    /**
     * 修正因 404 带来的 wordpress内置分页算法的链接错误问题
     * 比如:
     *   访问 http://www.zfkun.com/date/2010/01 时，上一页本来期望是http://www.zfkun.com/date/2010/01/page/2
     *   而实际，因为使用的404 rewrite技术，上一页链接却成了http://www.zfkun.com:80;/date/2010/01/page/3
     *   这是因为wp内置的分页算法直接使用了 $_SERVER['QUERY_STRING'] 和 $_SERVER["SCRIPT_NAME"] 来生成链接地址，
     *   当前因为是404状态下，所以 $_SERVER['QUERY_STRING'] = '404;http://www.zfkun.com:80/date/2010/01';
     * 注意:
     *   仅修改 $_SERVER['QUERY_STRING'] = '' 的话，并解决不了问题，因为当前执行脚本文件为/404.php 从而会导致
     *   生成的链接到  http://www.zfkun.com/404.php/date/2010/01 上去
     *   所以，必须还要重置 $_SERVER['SCRIPT_NAME'] = '/index.php' 从而让WP内置处理逻辑运行正常
     */
    $_SERVER['QUERY_STRING'] = '';
    $_SERVER["SCRIPT_NAME"] = '/index.php';

    // 启动博客主程序
...
} else {
// 真正的 404 处理
...
}
?&gt;</pre>
<p>5. 必须地，后台-&gt;固定链接-&gt;自定义结构 更新值为 /%post_id%.html<br />
这里又发现一个让我很郁闷的问题，若自定义结构使用的形如 /archives/%post_id%.html 或之前的 /index.php/archives/%post_id%<br />
则， 分类 和 标签的 路由默认也会增加这个前缀 /archives/tag/* /archives/category/* 擦，之前历史遗留的2种兼容结构，就是因为这个问题导致的，无奈。</p>
<p>6. 其余的乱七八糟的兼容，模糊了，回头想起来补记下</p>
<p>其实，做的工作远比现在记录的要多，只是让我印象深刻（那是好听的，其实我想说恶心的）的是这些。回头有时间继续更新好了。今天就先到这。</p>

	标签：<a href="http://www.zfkun.com/tag/404" title="404" rel="tag">404</a>, <a href="http://www.zfkun.com/tag/hack" title="hack" rel="tag">hack</a>, <a href="http://www.zfkun.com/tag/php" title="PHP" rel="tag">PHP</a>, <a href="http://www.zfkun.com/tag/rewrite" title="rewrite" rel="tag">rewrite</a>, <a href="http://www.zfkun.com/tag/seo" title="seo" rel="tag">seo</a>, <a href="http://www.zfkun.com/tag/wordpress" title="wordpress" rel="tag">wordpress</a><br />

	<h4>相关推荐</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.zfkun.com/344.html" title="WordPress 中文Tag 显示404错误的BUG修正 (2011 年 07 月 07 日)" data-comment="0">WordPress 中文Tag 显示404错误的BUG修正</a></li>
	<li><a href="http://www.zfkun.com/135.html" title="挑战 hax.tor.hu 申请带ssh的免费php+mysql空间 (2010 年 03 月 19 日)" data-comment="0">挑战 hax.tor.hu 申请带ssh的免费php+mysql空间</a></li>
	<li><a href="http://www.zfkun.com/39.html" title="基于OpenCV的PHP图像人脸识别技术 (2010 年 01 月 16 日)" data-comment="0">基于OpenCV的PHP图像人脸识别技术</a></li>
	<li><a href="http://www.zfkun.com/223.html" title="动态生成windows快捷方式文件 (2011 年 04 月 02 日)" data-comment="0">动态生成windows快捷方式文件</a></li>
	<li><a href="http://www.zfkun.com/74.html" title="wp_list_categories()参数说明 (2010 年 01 月 18 日)" data-comment="0">wp_list_categories()参数说明</a></li>
	<li><a href="http://www.zfkun.com/179.html" title="WordPress 3.1升级后无法访问 (2011 年 03 月 20 日)" data-comment="0">WordPress 3.1升级后无法访问</a></li>
	<li><a href="http://www.zfkun.com/102.html" title="Windows 下 Nginx + PHP5 的安装与配置 (2010 年 01 月 28 日)" data-comment="0">Windows 下 Nginx + PHP5 的安装与配置</a></li>
	<li><a href="http://www.zfkun.com/35.html" title="PHP CURL函数库 (2010 年 01 月 16 日)" data-comment="0">PHP CURL函数库</a></li>
	<li><a href="http://www.zfkun.com/95.html" title="Nginx 0.8.x + PHP 5.2.10（FastCGI）搭建胜过Apache十倍的Web服务器（第5版） (2010 年 01 月 28 日)" data-comment="0">Nginx 0.8.x + PHP 5.2.10（FastCGI）搭建胜过Apache十倍的Web服务器（第5版）</a></li>
	<li><a href="http://www.zfkun.com/366.html" title="Market Enabler &#8211; Android越狱改区利器 (2011 年 07 月 10 日)" data-comment="2">Market Enabler &#8211; Android越狱改区利器</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.zfkun.com/417.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>fastcgi_finish_request提速程序执行</title>
		<link>http://www.zfkun.com/229.html</link>
		<comments>http://www.zfkun.com/229.html#comments</comments>
		<pubDate>Wed, 13 Apr 2011 02:56:14 +0000</pubDate>
		<dc:creator>影之迷惑</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[开发编程]]></category>
		<category><![CDATA[fastcgi_finish_request]]></category>
		<category><![CDATA[异步]]></category>
		<category><![CDATA[提速]]></category>

		<guid isPermaLink="false">http://www.zfkun.com/blog/?p=229</guid>
		<description><![CDATA[当PHP运行在FastCGI模式时，PHP FPM提供了一个名为fastcgi_finish_request的方法。 <a href="http://www.zfkun.com/229.html">阅读全文 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>当PHP运行在FastCGI模式时，<a href="http://php-fpm.org/" target="_blank">PHP FPM</a>提供了一个名为<a href="http://php-fpm.org/wiki/Features#fastcgi_finish_request.28.29" target="_blank">fastcgi_finish_request</a>的方法。</p>
<p>不错的提速函数方法，针对页面生成完成后的任务执行可使用此方法。</p>
<p>例子：</p>
<pre name="code" class="php">&lt;?php
echo '页面生成内容';
fastcgi_finish_request();
echo '看不到的生成内容，因为页面生成早已结束';
file_put_contents('test.txt', '页面虽已结束，但是任务仍旧正常继续运行');
?&gt;</pre>
<p>&nbsp;</p>
<p>通过浏览器访问此PHP，由结果可说明在调用fastcgi_finish_request后，客户端响应就已经结束，但与此同时PHP剩余脚本代码却继续运行至最后。</p>
<p>&nbsp;</p>
<p>合理利用这个特性可以大大提升用户体验及性能：</p>
<pre name="code" class="php">&lt;?php
echo '给用户看的内容';
file_put_contents('test.txt', "页面生成完毕", FILE_APPEND);
fastcgi_finish_request();
sleep(5);
file_put_contents('test.txt', "任务A执行\n", FILE_APPEND);
sleep(5);
file_put_contents('test.txt', "任务B执行\n", FILE_APPEND);
?&gt;</pre>
<p>如预期，浏览时页面没有被堵塞，显示“给用户看的内容”并生成一条LOG记录后，请求就结束了。<br />
而剩余的任务A 和 B，却依旧照常执行。</p>

	标签：<a href="http://www.zfkun.com/tag/fastcgi_finish_request" title="fastcgi_finish_request" rel="tag">fastcgi_finish_request</a>, <a href="http://www.zfkun.com/tag/php" title="PHP" rel="tag">PHP</a>, <a href="http://www.zfkun.com/tag/%e5%bc%82%e6%ad%a5" title="异步" rel="tag">异步</a>, <a href="http://www.zfkun.com/tag/%e6%8f%90%e9%80%9f" title="提速" rel="tag">提速</a><br />

	<h4>相关推荐</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.zfkun.com/135.html" title="挑战 hax.tor.hu 申请带ssh的免费php+mysql空间 (2010 年 03 月 19 日)" data-comment="0">挑战 hax.tor.hu 申请带ssh的免费php+mysql空间</a></li>
	<li><a href="http://www.zfkun.com/39.html" title="基于OpenCV的PHP图像人脸识别技术 (2010 年 01 月 16 日)" data-comment="0">基于OpenCV的PHP图像人脸识别技术</a></li>
	<li><a href="http://www.zfkun.com/223.html" title="动态生成windows快捷方式文件 (2011 年 04 月 02 日)" data-comment="0">动态生成windows快捷方式文件</a></li>
	<li><a href="http://www.zfkun.com/417.html" title="WordPress Rewrite SEO 之404方式折腾笔记 (2011 年 07 月 17 日)" data-comment="1">WordPress Rewrite SEO 之404方式折腾笔记</a></li>
	<li><a href="http://www.zfkun.com/102.html" title="Windows 下 Nginx + PHP5 的安装与配置 (2010 年 01 月 28 日)" data-comment="0">Windows 下 Nginx + PHP5 的安装与配置</a></li>
	<li><a href="http://www.zfkun.com/35.html" title="PHP CURL函数库 (2010 年 01 月 16 日)" data-comment="0">PHP CURL函数库</a></li>
	<li><a href="http://www.zfkun.com/95.html" title="Nginx 0.8.x + PHP 5.2.10（FastCGI）搭建胜过Apache十倍的Web服务器（第5版） (2010 年 01 月 28 日)" data-comment="0">Nginx 0.8.x + PHP 5.2.10（FastCGI）搭建胜过Apache十倍的Web服务器（第5版）</a></li>
	<li><a href="http://www.zfkun.com/21.html" title="iconv 方法使用 (2010 年 01 月 16 日)" data-comment="0">iconv 方法使用</a></li>
	<li><a href="http://www.zfkun.com/33.html" title="domdocument::domdocument() expects at least 1 parameter解决办法 (2010 年 01 月 16 日)" data-comment="0">domdocument::domdocument() expects at least 1 parameter解决办法</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.zfkun.com/229.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>动态生成windows快捷方式文件</title>
		<link>http://www.zfkun.com/223.html</link>
		<comments>http://www.zfkun.com/223.html#comments</comments>
		<pubDate>Sat, 02 Apr 2011 07:52:01 +0000</pubDate>
		<dc:creator>影之迷惑</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[开发编程]]></category>
		<category><![CDATA[shortcut]]></category>
		<category><![CDATA[url]]></category>
		<category><![CDATA[快捷方式]]></category>

		<guid isPermaLink="false">http://www.zfkun.com/blog/?p=223</guid>
		<description><![CDATA[近期改版中涉及到此小需求。就看了下，其实挺简单，这里就做个简单记录，不需要分析了。简单的使用了PHP语言（其他也一样），扩展性很容易做（稍微做点可变处理就行），所以就没去刻意做，写死效率最高 - -。 <a href="http://www.zfkun.com/223.html">阅读全文 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>近期改版中涉及到此小需求。就看了下，其实挺简单，这里就做个简单记录，不需要分析了。</p>
<p>简单的使用了PHP语言（其他也一样），扩展性很容易做（稍微做点可变处理就行），所以就没去刻意做，写死效率最高 &#8211; -。</p>
<pre name="code" class="php">&lt;?php
$fileName = iconv("utf-8", "GBK", "7k7k小游戏");
header("Content-Type:application/octet-stream");
header("Content-Disposition:attachment;filename={$fileName}.url");
?&gt;[default]
BASEURL=http://www.7k7k.com/?ADTAG=deskto.home
[InternetShortcut]
URL=http://www.7k7k.com/?ADTAG=desktop.home
IconFile=http://www.7k7k.com/favicon.ico
IconIndex=1
HotKey=0
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,2</pre>

	标签：<a href="http://www.zfkun.com/tag/php" title="PHP" rel="tag">PHP</a>, <a href="http://www.zfkun.com/tag/shortcut" title="shortcut" rel="tag">shortcut</a>, <a href="http://www.zfkun.com/tag/url" title="url" rel="tag">url</a>, <a href="http://www.zfkun.com/tag/%e5%bf%ab%e6%8d%b7%e6%96%b9%e5%bc%8f" title="快捷方式" rel="tag">快捷方式</a><br />

	<h4>相关推荐</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.zfkun.com/135.html" title="挑战 hax.tor.hu 申请带ssh的免费php+mysql空间 (2010 年 03 月 19 日)" data-comment="0">挑战 hax.tor.hu 申请带ssh的免费php+mysql空间</a></li>
	<li><a href="http://www.zfkun.com/39.html" title="基于OpenCV的PHP图像人脸识别技术 (2010 年 01 月 16 日)" data-comment="0">基于OpenCV的PHP图像人脸识别技术</a></li>
	<li><a href="http://www.zfkun.com/417.html" title="WordPress Rewrite SEO 之404方式折腾笔记 (2011 年 07 月 17 日)" data-comment="1">WordPress Rewrite SEO 之404方式折腾笔记</a></li>
	<li><a href="http://www.zfkun.com/102.html" title="Windows 下 Nginx + PHP5 的安装与配置 (2010 年 01 月 28 日)" data-comment="0">Windows 下 Nginx + PHP5 的安装与配置</a></li>
	<li><a href="http://www.zfkun.com/35.html" title="PHP CURL函数库 (2010 年 01 月 16 日)" data-comment="0">PHP CURL函数库</a></li>
	<li><a href="http://www.zfkun.com/95.html" title="Nginx 0.8.x + PHP 5.2.10（FastCGI）搭建胜过Apache十倍的Web服务器（第5版） (2010 年 01 月 28 日)" data-comment="0">Nginx 0.8.x + PHP 5.2.10（FastCGI）搭建胜过Apache十倍的Web服务器（第5版）</a></li>
	<li><a href="http://www.zfkun.com/21.html" title="iconv 方法使用 (2010 年 01 月 16 日)" data-comment="0">iconv 方法使用</a></li>
	<li><a href="http://www.zfkun.com/229.html" title="fastcgi_finish_request提速程序执行 (2011 年 04 月 13 日)" data-comment="1">fastcgi_finish_request提速程序执行</a></li>
	<li><a href="http://www.zfkun.com/33.html" title="domdocument::domdocument() expects at least 1 parameter解决办法 (2010 年 01 月 16 日)" data-comment="0">domdocument::domdocument() expects at least 1 parameter解决办法</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.zfkun.com/223.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>挑战 hax.tor.hu 申请带ssh的免费php+mysql空间</title>
		<link>http://www.zfkun.com/135.html</link>
		<comments>http://www.zfkun.com/135.html#comments</comments>
		<pubDate>Fri, 19 Mar 2010 02:39:25 +0000</pubDate>
		<dc:creator>影之迷惑</dc:creator>
				<category><![CDATA[开发编程]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[hax]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[tor.hu]]></category>

		<guid isPermaLink="false">http://www.zfkun.com/blog/?p=135</guid>
		<description><![CDATA[hax.tor.hu 是一家提供带ssh的免费php+mysql虚拟主机的空间服务商，而且它的SSH隧道是开通的,但是想获得这一免费午餐，却让我大伤脑筋，因为它要求通 过它的五道变态难题才行 <a href="http://www.zfkun.com/135.html">阅读全文 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>hax.tor.hu  是一家提供带ssh的免费php+mysql虚拟主机的空间服务商，而且它的SSH隧道是开通的,但是想获得这一免费午餐，却让我大伤脑筋，因为它要求通 过它的五道变态难题才行。</p>
<p>打开 <a href="http://hax.tor.hu/warmup1/">http://hax.tor.hu/warmup1/</a> 开始猜解密码</p>
<p>1.这道题是用javascript设置的，提示“Password is in source.”说明密码就在网页之中，打开源码找到JS部分：</p>
<p>function a(){   thepw = ‘warmup1′;   thepw = thepw+’lol’;   thepw =  thepw + ‘copter’;<br />
if (document.lf.pw.value==thepw) {     document.location = ‘/’+thepw; }<br />
else { alert(‘That is not correct. Please try   again.’);   } }   看到了吧，密码是 “warmup1lolcopter”.</p>
<p>2.提示输入 <a href="http://www.fbi.gov/">www.fbi.gov</a> 的SSH标记，有几个了解这些的连接，然而，这些连接只是扰乱视听。SSH一般使用<br />
22 端口，所以使用 PUTTY 或者是 telnet 尝试。</p>
<p>telnet  <a href="http://www.fbi.gov/">www.fbi.gov</a> 22  之后，出现的字符  SSH-1.99-Server-VII 便是答案</p>
<p>3.提交 “Bacon” 的变量名称。<br />
这个简单，源码中的 select name=”chosen”&gt; 说明 name=”chosen” ，所以在当前的浏览器中输入 <a href="http://hax.tor.hu/warmup3/?chosen=Bacon">http://hax.tor.hu/warmup3/?chosen=Bacon</a> 回 车就到第四关。</p>
<p>4.提示 密码又在源码中，打开源码并没有找到任何密码，密码一定在网页的报头中，Telnet 看看</p>
<p>telnet hax.tor.hu 80</p>
<p>回车输入</p>
<p>GET /pwfor4/ HTTP/1.1</p>
<p>Host: hax.tor.hu</p>
<p>看到返回信息了。</p>
<p>HTTP/1.1 200 OK<br />
Transfer-Encoding: chunked 22 The password is: stickpick   DOS窗口自动关闭。密码提示为 stickdeath</p>
<p>5.最后的一道难题。提示是下面的字符串是被加密后的密码，意思是解密给出的数值就是密码68 228 94 125 67 210 82 19</p>
<p>胡乱输入一个字符回车后，晕倒：Hash ！！！也就说给出的那些数字是密码的 哈希 值，而 哈希 算法从来有名</p>
<p>尝试了几次之后，发现这也不是什么 哈希 目前是 site</p>
<p>破解方法： 两个数字的组合，代表一个字母，三个数字的组合标记位数，所以不用理睬三个数字的组合，也不用管最后两个数字的组合。</p>
<p>对应表单</p>
<p>a 77<br />
b 78<br />
c 79<br />
d 72<br />
e 73<br />
f 74<br />
g 75<br />
h 68<br />
i 69<br />
j 70<br />
k 71<br />
l 64<br />
m 65<br />
n 66<br />
o 67<br />
p 92<br />
r 94<br />
s 95<br />
t 88<br />
u 89<br />
w 91<br />
z 86</p>
<p>比如：68 228 94 125 67 210 82 19 就是 site</p>
<p><span style="color: #ff0000;">(由于官方的这个对应表会随机的变化，所以实际情况请自行测试出对应表填写即可)</span></p>
<p>===============================================<br />
过了这五道难关，就可以申请账号了。输入账号，Email 后就去收邮件，收到邮件就登陆。</p>
<p><a href="https://hax.tor.hu/login">https://hax.tor.hu/login</a> 刚一登陆，就面对的是 Challenges Level 1，就是输入一个符合其要求的URL<span style="color: #ff0000;">（其实很简单，也是混乱视听的）</span>。</p>
<p>不过别担心，不用理睬Challenges Level，点左栏的 [ Shell ]，申请 shell 账号，账号密码会邮件给你。</p>
<p>下来开始配置  VHOST ,<br />
配置空间大小，选 2000M 后点 “Update quota”,点 Web Setup 添加域名，在三个框中按照提示输入：</p>
<p><span style="color: #ff0000;">你的账号</span>.shell.tor.hu       www.<span style="color: #ff0000;">你的账号</span>.shell.tor.hu          /home/你的账号/www<span style="color: #ff0000;">（记得登陆空间后自行创建）</span></p>
<p>点 “Add vhost” 完成。</p>
<p>也可以输入自己的域名，但需要做CNAME 或者是 A 记录。这里是说明文件<a href="http://shell.tor.hu/doc/web.txt"> http://shell.tor.hu/doc/web.txt</a></p>
<p>终于完成了申请，开始传文件。</p>
<p>现在打开 http://你的账号.shell.tor.hu  就能访问你的主页了。</p>

	标签：<a href="http://www.zfkun.com/tag/free" title="free" rel="tag">free</a>, <a href="http://www.zfkun.com/tag/hax" title="hax" rel="tag">hax</a>, <a href="http://www.zfkun.com/tag/mysql" title="mysql" rel="tag">mysql</a>, <a href="http://www.zfkun.com/tag/php" title="PHP" rel="tag">PHP</a>, <a href="http://www.zfkun.com/tag/ssh" title="ssh" rel="tag">ssh</a>, <a href="http://www.zfkun.com/tag/tor-hu" title="tor.hu" rel="tag">tor.hu</a><br />

	<h4>相关推荐</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.zfkun.com/95.html" title="Nginx 0.8.x + PHP 5.2.10（FastCGI）搭建胜过Apache十倍的Web服务器（第5版） (2010 年 01 月 28 日)" data-comment="0">Nginx 0.8.x + PHP 5.2.10（FastCGI）搭建胜过Apache十倍的Web服务器（第5版）</a></li>
	<li><a href="http://www.zfkun.com/426.html" title="无需翻墙Youtube流畅访问之HOSTS绑定 (2011 年 07 月 19 日)" data-comment="1">无需翻墙Youtube流畅访问之HOSTS绑定</a></li>
	<li><a href="http://www.zfkun.com/39.html" title="基于OpenCV的PHP图像人脸识别技术 (2010 年 01 月 16 日)" data-comment="0">基于OpenCV的PHP图像人脸识别技术</a></li>
	<li><a href="http://www.zfkun.com/223.html" title="动态生成windows快捷方式文件 (2011 年 04 月 02 日)" data-comment="0">动态生成windows快捷方式文件</a></li>
	<li><a href="http://www.zfkun.com/417.html" title="WordPress Rewrite SEO 之404方式折腾笔记 (2011 年 07 月 17 日)" data-comment="1">WordPress Rewrite SEO 之404方式折腾笔记</a></li>
	<li><a href="http://www.zfkun.com/102.html" title="Windows 下 Nginx + PHP5 的安装与配置 (2010 年 01 月 28 日)" data-comment="0">Windows 下 Nginx + PHP5 的安装与配置</a></li>
	<li><a href="http://www.zfkun.com/35.html" title="PHP CURL函数库 (2010 年 01 月 16 日)" data-comment="0">PHP CURL函数库</a></li>
	<li><a href="http://www.zfkun.com/21.html" title="iconv 方法使用 (2010 年 01 月 16 日)" data-comment="0">iconv 方法使用</a></li>
	<li><a href="http://www.zfkun.com/229.html" title="fastcgi_finish_request提速程序执行 (2011 年 04 月 13 日)" data-comment="1">fastcgi_finish_request提速程序执行</a></li>
	<li><a href="http://www.zfkun.com/33.html" title="domdocument::domdocument() expects at least 1 parameter解决办法 (2010 年 01 月 16 日)" data-comment="0">domdocument::domdocument() expects at least 1 parameter解决办法</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.zfkun.com/135.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows 下 Nginx + PHP5 的安装与配置</title>
		<link>http://www.zfkun.com/102.html</link>
		<comments>http://www.zfkun.com/102.html#comments</comments>
		<pubDate>Thu, 28 Jan 2010 15:26:33 +0000</pubDate>
		<dc:creator>影之迷惑</dc:creator>
				<category><![CDATA[开发编程]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.zfkun.com/blog/?p=102</guid>
		<description><![CDATA[Nginx 是一个轻量级的高性能 Http WebServer，以事件驱动方式编写，因此相比 Apache 而言，Nginx 更加稳定、性能更好，而且配置简单，资源占用较低。以下是在 Windows 7 安装中 Nginx 和 PHP5.3 的步骤。 <a href="http://www.zfkun.com/102.html">阅读全文 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Nginx 是一个轻量级的高性能 Http WebServer，以事件驱动方式编写，因此相比 Apache 而言，Nginx 更加稳定、性能更好，而且配置简单，资源占用较低。以下是在 Windows 7 安装中 Nginx 和 PHP5.3 的步骤。</p>
<p><strong>安装 PHP5<br />
</strong>首先，从 http://www.php.net/downloads.php 下载最新的 PHP 5.3 Windows 版本，解压至 C:\php5，把压缩包中的 php.ini-recommended，更名为 php.ini，然后打开修改几个选项：</p>
<p name="code" class="c">
error_reporting = E_ALL<br />
display_errors = On<br />
extension_dir = “C:\php5\ext”</p>
<p>; 动态扩展，可以根据需要去掉 extension 前面的注释 ;<br />
; 如加载 PDO, MySQL<br />
extension=php_pdo.dll<br />
extension=php_pdo_mysql.dll</p>
<p>; CGI 设置<br />
cgi.fix_pathinfo = 1
</p>
<p>PHP 加载扩展需要注意依赖性，比如 php_exif.dll 需要 php_mbstring.dll，你必须要把 php_mbstring.dll 放在 php_exif.dll 前面才能加载成功。有些扩展依赖额外的 dll 文件，如 PHP 5.0+ ，php_mysqli.dll 依赖 libmysql.dll，而 php_oci8.dll，你则需要安装 Oracle 8 的客户端。如果你对这些依赖性不是太了解，可以参考一下安装包中的 install.txt 文件。</p>
<p>依赖文件的搜索顺序：首先是 php.exe 所在的目录，如果是 ISAPI 模式，那么会搜索 Web Server 的启动位置，比如 Apache 的 bin 目录；其次是 Windows PATH 环境变量中的目录。这里不要复制任何文件到 Windows 目录中，有必要的话，可以把 C:\php5 加到 PATH 中，便于以后 PHP 的升级。</p>
<p><strong>安装 Nginx</strong><br />
从 v0.7.52 开始，Nginx 开始发布 Windows 版本的 Nginx，你可以在其官方网站上面下载：</p>
<p>http://nginx.net</p>
<p>如果需要老版本的 Nginx for Windows，可以在 Kevin Worthington 的网站上面找找。</p>
<p>我使用的是 0.8.29，下载好以后，解压释放文件到 C:\nginx。</p>
<p>那么如何配置 Nginx，使其可以和 PHP 协同工作？</p>
<p><strong>配置 PHP FastCGI<br />
</strong>Nginx 需要和 FastCGI Server 配合才能处理请求，有两种方式运行 PHP FastCGI Server，一种就是使用 PHP 内置的 FastCGI 管理器：</p>
<p name="code" class="c">
C:/php5/php-cgi.exe -b 127.0.0.1:9000 -c C:/php5/php.ini
</p>
<p>另外一种方式是使用第三方工具，比如 PHP-FPM 、cgi-fcgi 等。显然！要在 Windows 中使用这些工具是件极其痛苦的事情，你可能需要 Cygwin 之类的东西才行，的确有人这么做了，虽然我觉得那是自寻烦恼。</p>
<p>下一步，修改 Nginx ，将 php 请求转发至 PHP FastCGI Server：</p>
<p name="code" class="c">
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000<br />
location ~ ^(.+\.php)(.*)$ {<br />
root D:/public_html;<br />
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;<br />
include php.conf;<br />
}
</p>
<p>root 也就是 $document_root 指的是你的 php scripts 根目录，设置为你的网站根目录。在 Windows 下，需要注意的是 root 的路径，最好使用 “/” 作为路径分隔符，而不是 Windows 默认的 “\”，否则容易出问题，比如，这个路径：D:\public_html\test，就不会起作用，Nginx 会抛出 500 错误，原因是 \test 中 \t 被解析为制表符。当然再加上一个反斜杠转义也是可以的，如：D:\\public_html\\test。</p>
<p>php.conf 配置文件：</p>
<p name="code" class="c">
# 连接到本机 9000 端口，这里的端口是指 PHP FastCGI Server 开启的端口，<br />
# 请与 php-cgi.exe 开启的端口保持一致<br />
# 当 Nginx 收到 php 文件的请求时，会自动转发到 PHP FastCGI Server<br />
fastcgi_pass 127.0.0.1:9000;<br />
fastcgi_index index.php;</p>
<p># Nginx 默认是不支持 CGI PATH_INFO，SCRIPT_NAME 的值也不标准（糅合了 PATH_INFO）<br />
# 下面的两行指令，可以从 SCRIPT_NAME 中剥离出 PATH_INFO<br />
fastcgi_split_path_info ^(.+\.php)(.*)$;<br />
fastcgi_param PATH_INFO $fastcgi_path_info;</p>
<p>include fastcgi_params;
</p>
<p>创建一个独立的 php.conf 保存配置，纯粹是为了精简 nginx.conf，个人习惯而已，也可以全部写在主配置文件中。</p>
<p>修改 php.ini，设置 cgi.fix_pathinfo = 1，这非常重要，PHP 会修正 SCRIPT_FILENAME 为真实的文件地址，否则 PHP 将无法找到需要处理的 php 文件。</p>
<p>一些其他的设置，主服务器：</p>
<p name="code" class="c">
# 默认开启的进程数<br />
worker_processes 1;</p>
<p>error_log logs/error.log;<br />
#error_log logs/error.log notice;<br />
#error_log logs/error.log info;</p>
<p>#pid logs/nginx.pid;</p>
<p>events {<br />
# 一个进程所处理的最大连接数上限，<br />
# 本地开发，不需要默认的 1024，这里改为 64<br />
worker_connections 64;<br />
}
</p>
<p>当某个目录下面不存在默认 index.php index.html 等首页文件时，Nginx 会抛出 403 ERROR，如果你需要罗列此目录，则可以在 http {… } 中加入如下命令：</p>
<p name="code" class="c">
autoindex on;<br />
autoindex_exact_size on;<br />
autoindex_localtime on;
</p>
<p><strong>OK，整合到一起</strong><br />
创建 start_nginx.bat，用于同时启动 PHP FastCGI 和 Nginx：</p>
<p name="code" class="c">
@echo off<br />
REM Windows 下无效<br />
REM set PHP_FCGI_CHILDREN=5</p>
<p>REM 每个进程处理的最大请求数，或设置为 Windows 环境变量<br />
set PHP_FCGI_MAX_REQUESTS=1000</p>
<p>echo Starting PHP FastCGI&#8230;<br />
RunHiddenConsole C:/php5/php-cgi.exe -b 127.0.0.1:9000 -c C:/php5/php.ini</p>
<p>echo Starting nginx&#8230;<br />
C:/nginx/nginx.exe
</p>
<p>RunHiddenConsole.exe 是一个用来隐藏 DOS 窗口的小程序，可以在这里下载。<br />
start_nginx.bat 开启后，也会有 DOS 窗口，但是可以安全的关掉，并不会关闭 Nginx 和 php-cgi.exe。</p>
<p>同样 stop_nginx.bat，用来关闭：</p>
<p name="code" class="c">
@echo off<br />
echo Stopping nginx&#8230;<br />
taskkill /F /IM nginx.exe &gt; nul<br />
echo Stopping PHP FastCGI&#8230;<br />
taskkill /F /IM php-cgi.exe &gt; nul<br />
exit
</p>
<p>到这里基本配置完毕了。</p>

	标签：<a href="http://www.zfkun.com/tag/nginx" title="nginx" rel="tag">nginx</a>, <a href="http://www.zfkun.com/tag/php" title="PHP" rel="tag">PHP</a>, <a href="http://www.zfkun.com/tag/windows" title="windows" rel="tag">windows</a><br />

	<h4>相关推荐</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.zfkun.com/95.html" title="Nginx 0.8.x + PHP 5.2.10（FastCGI）搭建胜过Apache十倍的Web服务器（第5版） (2010 年 01 月 28 日)" data-comment="0">Nginx 0.8.x + PHP 5.2.10（FastCGI）搭建胜过Apache十倍的Web服务器（第5版）</a></li>
	<li><a href="http://www.zfkun.com/135.html" title="挑战 hax.tor.hu 申请带ssh的免费php+mysql空间 (2010 年 03 月 19 日)" data-comment="0">挑战 hax.tor.hu 申请带ssh的免费php+mysql空间</a></li>
	<li><a href="http://www.zfkun.com/277.html" title="微软MSDN windows 7 with sp1 中英文各版本x86x64下载地址 (2011 年 06 月 25 日)" data-comment="1">微软MSDN windows 7 with sp1 中英文各版本x86x64下载地址</a></li>
	<li><a href="http://www.zfkun.com/39.html" title="基于OpenCV的PHP图像人脸识别技术 (2010 年 01 月 16 日)" data-comment="0">基于OpenCV的PHP图像人脸识别技术</a></li>
	<li><a href="http://www.zfkun.com/223.html" title="动态生成windows快捷方式文件 (2011 年 04 月 02 日)" data-comment="0">动态生成windows快捷方式文件</a></li>
	<li><a href="http://www.zfkun.com/417.html" title="WordPress Rewrite SEO 之404方式折腾笔记 (2011 年 07 月 17 日)" data-comment="1">WordPress Rewrite SEO 之404方式折腾笔记</a></li>
	<li><a href="http://www.zfkun.com/226.html" title="Windows7下搭建Node.js环境 (2011 年 04 月 06 日)" data-comment="1">Windows7下搭建Node.js环境</a></li>
	<li><a href="http://www.zfkun.com/51.html" title="windows7 7068 X86三版本及下载 (2010 年 01 月 16 日)" data-comment="0">windows7 7068 X86三版本及下载</a></li>
	<li><a href="http://www.zfkun.com/449.html" title="Thinkpad 全系列驱动程序官方安装光盘下载 (2011 年 11 月 17 日)" data-comment="0">Thinkpad 全系列驱动程序官方安装光盘下载</a></li>
	<li><a href="http://www.zfkun.com/35.html" title="PHP CURL函数库 (2010 年 01 月 16 日)" data-comment="0">PHP CURL函数库</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.zfkun.com/102.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nginx 0.8.x + PHP 5.2.10（FastCGI）搭建胜过Apache十倍的Web服务器（第5版）</title>
		<link>http://www.zfkun.com/95.html</link>
		<comments>http://www.zfkun.com/95.html#comments</comments>
		<pubDate>Wed, 27 Jan 2010 16:40:35 +0000</pubDate>
		<dc:creator>影之迷惑</dc:creator>
				<category><![CDATA[开发编程]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[apc]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[epoll]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[httpd]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[memcache]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[xcache]]></category>

		<guid isPermaLink="false">http://www.zfkun.com/blog/?p=95</guid>
		<description><![CDATA[本文是张宴撰写的关于搭建“Nginx + PHP（FastCGI）”Web服务器的第5篇文章。本系列文章作为国内最早详细介绍 Nginx + PHP 安装、配置、使用的资料之一，为推动 Nginx 在国内的发展产生了积极的作用。这是一篇关于Nginx 0.7.x系列版本的文章，安装、配置方式与第4篇文章相差不大，但增加了MySQL安装配置的信息、PHP 5.2.10 的 php-fpm 补丁。Nginx 0.7.x系列版本虽然为开发版，但在很多大型网站的生产环境中已经使用。 <a href="http://www.zfkun.com/95.html">阅读全文 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>[文章作者：张宴 本文版本：v5.5 最后修改：2009.09.18 原文链接：<a href="http://blog.s135.com/nginx_php_v5/" target="_blank">http://blog.s135.com/nginx_php_v5/</a>]</p>
<p>前言：本文是我撰写的关于搭建“Nginx + PHP（FastCGI）”Web服务器的第5篇文章。本系列文章作为国内最早详细介绍 Nginx + PHP 安装、配置、使用的资料之一，为推动 Nginx 在国内的发展产生了积极的作用。这是一篇关于Nginx 0.7.x系列版本的文章，安装、配置方式与第4篇文章相差不大，但增加了MySQL安装配置的信息、<strong>PHP 5.2.10 的 php-fpm 补丁</strong>。Nginx 0.7.x系列版本虽然为开发版，但在很多大型网站的生产环境中已经使用。</p>
<p>链接：《<a href="http://blog.s135.com/post/297/" target="_blank">2007年9月的第1版</a>》、《<a href="http://blog.s135.com/post/314/" target="_blank">2007年12月的第2版</a>》、《<a href="http://blog.s135.com/post/351/" target="_blank">2008年6月的第3版</a>》、《<a href="http://blog.s135.com/nginx_php_v4/" target="_blank">2008年8月的第4版</a>》</p>
<p><a href="http://blog.s135.com/attachment/200806/nginx.png" target="_blank"><img title="点击在新窗口中浏览此图片" src="http://blog.s135.com/attachment/200806/nginx.png" alt="点击在新窗口中浏览此图片" border="0" /></a></p>
<p><a href="http://www.nginx.net/" target="_blank">Nginx</a> (“engine x”) 是一个高性能的 HTTP 和反向代理服务器，也是一个 IMAP/POP3/SMTP 代理服务器。 Nginx 是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler.ru 站点开发的，它已经在该站点运行超过两年半了。Igor 将源代码以类BSD许可证的形式发布。</p>
<p>Nginx 超越 Apache 的高性能和稳定性，使得国内使用 Nginx 作为 Web 服务器的网站也越来越多，其中包括<a href="http://blog.sina.com.cn/" target="_blank">新浪博客</a>、<a href="http://v.sina.com.cn/" target="_blank">新浪播客</a>、<a href="http://news.163.com/" target="_blank">网易新闻</a>等门户网站频道，<a href="http://www.6.cn/" target="_blank">六间房</a>、<a href="http://www.56.com/" target="_blank">56.com</a>等视频分享网站，<a href="http://www.discuz.net/" target="_blank">Discuz!官方论坛</a>、<a href="http://www.newsmth.net/" target="_blank">水木社区</a>等知名论坛，<a href="http://www.douban.com/" target="_blank">豆瓣</a>、<a href="http://www.yupoo.com/" target="_blank">YUPOO相册</a>、<a href="http://www.hainei.com/" target="_blank">海内SNS</a>、<a href="http://www.xunlei.com/" target="_blank">迅雷在线</a>等新兴Web 2.0网站。</p>
<p>Nginx 的官方中文维基：<a href="http://wiki.nginx.org/NginxChs" target="_blank">http://wiki.nginx.org/NginxChs</a></p>
<p>在高并发连接的情况下，Nginx是Apache服务器不错的替代品。Nginx同时也可以作为7层负载均衡服务器来使用。根据我的测试结果，<strong>Nginx 0.8.15 + PHP 5.2.10 (FastCGI) 可以承受3万以上的并发连接数，相当于同等环境下Apache的10倍</strong>。</p>
<p>根据我的经验，4GB内存的服务器+Apache（prefork模式）一般只能处理3000个并发连接，因为它们将占用3GB以上的内存，还得为系统预留1GB的内存。我曾经就有两台Apache服务器，因为在配置文件中设置的MaxClients为4000，当Apache并发连接数达到3800时，导致服务器内存和Swap空间用满而崩溃。</p>
<p>而这台 Nginx 0.8.15 + PHP 5.2.10 (FastCGI) 服务器在3万并发连接下，开启的10个Nginx进程消耗150M内存（15M*10=150M），开启的64个php-cgi进程消耗1280M内存（20M*64=1280M），加上系统自身消耗的内存，总共消耗不到2GB内存。如果服务器内存较小，完全可以只开启25个php-cgi进程，这样php-cgi消耗的总内存数才500M。</p>
<p>在3万并发连接下，访问Nginx 0.8.15 + PHP 5.2.10 (FastCGI) 服务器的PHP程序，仍然速度飞快。下图为Nginx的状态监控页面，显示的活动连接数为28457（关于Nginx的监控页配置，会在本文接下来所给出的Nginx配置文件中写明）：</p>
<p><a href="http://blog.s135.com/attachment/200712/nginx_status.png" target="_blank"><img title="点击在新窗口中浏览此图片" src="http://blog.s135.com/attachment/200712/nginx_status.png" alt="点击在新窗口中浏览此图片" border="0" /></a></p>
<p>我生产环境下的两台Nginx + PHP5（FastCGI）服务器，跑多个一般复杂的纯PHP动态程序，单台Nginx + PHP5（FastCGI）服务器跑PHP动态程序的处理能力已经超过“700次请求/秒”，相当于每天可以承受6000万（700*60*60*24=60480000）的访问量（<a href="http://blog.s135.com/read.php/334.htm" target="_blank">更多信息见此</a>），而服务器的系统负载也不高：</p>
<p><a href="http://blog.s135.com/attachment/200803/nginx_php_la.gif" target="_blank"><img title="点击在新窗口中浏览此图片" src="http://blog.s135.com/attachment/200803/nginx_php_la.gif" alt="点击在新窗口中浏览此图片" border="0" /></a></p>
<p>2009年9月3日下午2：30，金山游戏《剑侠情缘网络版叁》临时维护1小时（<a href="http://kefu.xoyo.com/gonggao/jx3/2009-09-03/750438.shtml" target="_blank">http://kefu.xoyo.com/gonggao/jx3/2009-09-03/750438.shtml</a>），大量玩家上官网，论坛、评论、客服等动态应用Nginx服务器集群，每台服务器的Nginx活动连接数达到2.8万，这是笔者遇到的Nginx生产环境最高并发值。</p>
<p><a href="http://blog.s135.com/attachment/200909/nginx_c30k.png" target="_blank"><img title="点击在新窗口中浏览此图片" src="http://blog.s135.com/attachment/200909/nginx_c30k.png" alt="点击在新窗口中浏览此图片" border="0" /></a></p>
<hr />
<p>下面是用100个并发连接分别去压生产环境中同一负载均衡器VIP下、提供相同服务的两台服务器，一台为Nginx，另一台为Apache，Nginx每秒处理的请求数是Apache的两倍多，Nginx服务器的系统负载、CPU使用率远低于Apache：</p>
<p>你可以将连接数开到10000～30000，去压Nginx和Apache上的phpinfo.php，这是用浏览器访问Nginx上的phpinfo.php一切正常，而访问Apache服务器的phpinfo.php，则是该页无法显示。4G内存的服务器，即使再优化，Apache也很难在“webbench -c 30000 -t 60 http://xxx.xxx.xxx.xxx/phpinfo.php”的压力情况下正常访问，而调整参数优化后的Nginx可以。</p>
<p>webbench 下载地址：<a href="http://blog.s135.com/post/288/" target="_blank">http://blog.s135.com/post/288/</a></p>
<p>注意：webbench 做压力测试时，该软件自身也会消耗CPU和内存资源，为了测试准确，请将 webbench 安装在别的服务器上。</p>
<p>测试结果：##### Nginx + PHP #####</p>
<p class="c">[root@localhost webbench-1.5]# webbench -c 100 -t 30 http://192.168.1.21/phpinfo.php<br />
Webbench &#8211; Simple Web Benchmark 1.5<br />
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.</p>
<p>Benchmarking: GET http://192.168.1.21/phpinfo.php<br />
100 clients, running 30 sec.</p>
<p>Speed=102450 pages/min, 16490596 bytes/sec.<br />
Requests: 51225 susceed, 0 failed.</p>
<p>top &#8211; 14:06:13 up 27 days,  2:25,  2 users,  load average: 14.57, 9.89, 6.51<br />
Tasks: 287 total,   4 running, 283 sleeping,   0 stopped,   0 zombie<br />
Cpu(s): 49.9% us,  6.7% sy,  0.0% ni, 41.4% id,  1.1% wa,  0.1% hi,  0.8% si<br />
Mem:   6230016k total,  2959468k used,  3270548k free,   635992k buffers<br />
Swap:  2031608k total,     3696k used,  2027912k free,  1231444k cached</p>
<p>测试结果：#####  Apache + PHP #####</p>
<p class="c">[root@localhost webbench-1.5]# webbench -c 100 -t 30 http://192.168.1.27/phpinfo.php<br />
Webbench &#8211; Simple Web Benchmark 1.5<br />
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.</p>
<p>Benchmarking: GET http://192.168.1.27/phpinfo.php<br />
100 clients, running 30 sec.</p>
<p>Speed=42184 pages/min, 31512914 bytes/sec.<br />
Requests: 21092 susceed, 0 failed.</p>
<p>top &#8211; 14:06:20 up 27 days,  2:13,  2 users,  load average: 62.15, 26.36, 13.42<br />
Tasks: 318 total,   7 running, 310 sleeping,   0 stopped,   1 zombie<br />
Cpu(s): 80.4% us, 10.6% sy,  0.0% ni,  7.9% id,  0.1% wa,  0.1% hi,  0.9% si<br />
Mem:   6230016k total,  3075948k used,  3154068k free,   379896k buffers<br />
Swap:  2031608k total,    12592k used,  2019016k free,  1117868k cached</p>
<p>为什么Nginx的性能要比Apache高得多？这得益于Nginx使用了最新的epoll（Linux 2.6内核）和kqueue（freebsd）网络I/O模型，而Apache则使用的是传统的select模型。目前Linux下能够承受高并发访问的Squid、Memcached都采用的是epoll网络I/O模型。</p>
<p>处理大量的连接的读写，Apache所采用的select网络I/O模型非常低效。下面用一个比喻来解析Apache采用的select模型和Nginx采用的epoll模型进行之间的区别：</p>
<p>假设你在大学读书，住的宿舍楼有很多间房间，你的朋友要来找你。select版宿管大妈就会带着你的朋友挨个房间去找，直到找到你为止。而epoll版宿管大妈会先记下每位同学的房间号，你的朋友来时，只需告诉你的朋友你住在哪个房间即可，不用亲自带着你的朋友满大楼找人。如果来了10000个人，都要找自己住这栋楼的同学时，select版和epoll版宿管大妈，谁的效率更高，不言自明。同理，在高并发服务器中，轮询I/O是最耗时间的操作之一，select和epoll的性能谁的性能更高，同样十分明了。</p>
<p>安装步骤：<br />
（系统要求：Linux 2.6+ 内核，本文中的Linux操作系统为CentOS 5.3，另在RedHat AS4上也安装成功）<br />
<strong>一、获取相关开源程序：</strong><br />
1、【适用CentOS操作系统】利用CentOS Linux系统自带的yum命令安装、升级所需的程序库（RedHat等其他Linux发行版可从安装光盘中找到这些程序库的RPM包，进行安装）：</p>
<p class="c">sudo -s<br />
LANG=C<br />
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers</p>
<p>2、【适用RedHat操作系统】RedHat等其他Linux发行版可从安装光盘中找到这些程序库的RPM包（事先可通过类似“rpm -qa | grep libjpeg”的命令查看所需的RPM包是否存在，通常是“xxx-devel”不存在，需要安装）。RedHat可以直接利用CentOS的RPM包安装，以下是RPM包下载网址：<br />
①、RedHat AS4 &amp; CentOS 4<br />
<a href="http://mirrors.163.com/centos/4/os/i386/CentOS/RPMS/" target="_blank">http://mirrors.163.com/centos/4/os/i386/CentOS/RPMS/</a><br />
<a href="http://mirrors.163.com/centos/4/os/x86_64/CentOS/RPMS/" target="_blank">http://mirrors.163.com/centos/4/os/x86_64/CentOS/RPMS/</a></p>
<p>②、RedHat AS5 &amp; CentOS 5<br />
<a href="http://mirrors.163.com/centos/5/os/i386/CentOS/" target="_blank">http://mirrors.163.com/centos/5/os/i386/CentOS/</a><br />
<a href="http://mirrors.163.com/centos/5/os/x86_64/CentOS/" target="_blank">http://mirrors.163.com/centos/5/os/x86_64/CentOS/</a></p>
<p>③、RPM包搜索网站<br />
<a href="http://rpm.pbone.net/" target="_blank">http://rpm.pbone.net/</a><br />
<a href="http://www.rpmfind.net/" target="_blank">http://www.rpmfind.net/</a></p>
<p>④、RedHat AS4 系统环境，通常情况下缺少的支持包安装：<br />
Ⅰ、i386 系统</p>
<p class="c">wget http://blog.s135.com/soft/linux/nginx_php/rpm/i386/libjpeg-devel-6b-33.i386.rpm<br />
rpm -ivh libjpeg-devel-6b-33.i386.rpm<br />
wget http://blog.s135.com/soft/linux/nginx_php/rpm/i386/freetype-devel-2.1.9-1.i386.rpm<br />
rpm -ivh freetype-devel-2.1.9-1.i386.rpm<br />
wget http://blog.s135.com/soft/linux/nginx_php/rpm/i386/libpng-devel-1.2.7-1.i386.rpm<br />
rpm -ivh libpng-devel-1.2.7-1.i386.rpm</p>
<p>Ⅱ、x86_64 系统</p>
<p class="c">wget http://blog.s135.com/soft/linux/nginx_php/rpm/x86_64/libjpeg-devel-6b-33.x86_64.rpm<br />
rpm -ivh libjpeg-devel-6b-33.x86_64.rpm<br />
wget http://blog.s135.com/soft/linux/nginx_php/rpm/x86_64/freetype-devel-2.1.9-1.x86_64.rpm<br />
rpm -ivh freetype-devel-2.1.9-1.x86_64.rpm<br />
wget http://blog.s135.com/soft/linux/nginx_php/rpm/x86_64/libpng-devel-1.2.7-1.x86_64.rpm<br />
rpm -ivh libpng-devel-1.2.7-1.x86_64.rpm</p>
<p>3、【适用CentOS、RedHat及其它Linux操作系统】下载程序源码包：<br />
本文中提到的所有开源软件为截止到2009年09月18日的最新稳定版。<br />
①、从软件的官方网站下载：</p>
<p class="c">mkdir -p /data0/software<br />
cd /data0/software<br />
wget http://sysoev.ru/nginx/nginx-0.8.15.tar.gz<br />
wget http://www.php.net/get/php-5.2.10.tar.gz/from/this/mirror<br />
wget http://blog.s135.com/soft/linux/nginx_php/phpfpm/php-5.2.10-fpm-0.5.11.diff.gz<br />
wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.38.tar.gz/from/http://mysql.he.net/<br />
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.tar.gz<br />
wget http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz?modtime=1171868460&amp;big_mirror=0<br />
wget http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz?modtime=1194463373&amp;big_mirror=0<br />
wget http://pecl.php.net/get/memcache-2.2.5.tgz<br />
wget http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz?modtime=1175740843&amp;big_mirror=0<br />
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.9.tar.gz<br />
wget http://bart.eaccelerator.net/source/0.9.5.3/eaccelerator-0.9.5.3.tar.bz2<br />
wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz<br />
wget http://blog.s135.com/soft/linux/nginx_php/imagick/ImageMagick.tar.gz<br />
wget http://pecl.php.net/get/imagick-2.2.2.tgz</p>
<p>②、从blog.s135.com下载（比较稳定，只允许在本站，或者在Linux/Unix下通过Wget、Curl等命令下载以下软件）：</p>
<p class="c">mkdir -p /data0/software<br />
cd /data0/software<br />
wget http://blog.s135.com/soft/linux/nginx_php/nginx/nginx-0.8.15.tar.gz<br />
wget http://blog.s135.com/soft/linux/nginx_php/php/php-5.2.10.tar.gz<br />
wget http://blog.s135.com/soft/linux/nginx_php/phpfpm/php-5.2.10-fpm-0.5.11.diff.gz<br />
wget http://blog.s135.com/soft/linux/nginx_php/mysql/mysql-5.1.38.tar.gz<br />
wget http://blog.s135.com/soft/linux/nginx_php/libiconv/libiconv-1.13.tar.gz<br />
wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/libmcrypt-2.5.8.tar.gz<br />
wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/mcrypt-2.6.8.tar.gz<br />
wget http://blog.s135.com/soft/linux/nginx_php/memcache/memcache-2.2.5.tgz<br />
wget http://blog.s135.com/soft/linux/nginx_php/mhash/mhash-0.9.9.9.tar.gz<br />
wget http://blog.s135.com/soft/linux/nginx_php/pcre/pcre-7.9.tar.gz<br />
wget http://blog.s135.com/soft/linux/nginx_php/eaccelerator/eaccelerator-0.9.5.3.tar.bz2<br />
wget http://blog.s135.com/soft/linux/nginx_php/pdo/PDO_MYSQL-1.0.2.tgz<br />
wget http://blog.s135.com/soft/linux/nginx_php/imagick/ImageMagick.tar.gz<br />
wget http://blog.s135.com/soft/linux/nginx_php/imagick/imagick-2.2.2.tgz</p>
<p><strong>二、安装PHP 5.2.10（FastCGI模式）</strong><br />
1、编译安装PHP 5.2.10所需的支持库：</p>
<p class="c">tar zxvf libiconv-1.13.tar.gz<br />
cd libiconv-1.13/<br />
./configure &#8211;prefix=/usr/local<br />
make<br />
make install<br />
cd ../</p>
<p>tar zxvf libmcrypt-2.5.8.tar.gz<br />
cd libmcrypt-2.5.8/<br />
./configure<br />
make<br />
make install<br />
/sbin/ldconfig<br />
cd libltdl/<br />
./configure &#8211;enable-ltdl-install<br />
make<br />
make install<br />
cd ../../</p>
<p>tar zxvf mhash-0.9.9.9.tar.gz<br />
cd mhash-0.9.9.9/<br />
./configure<br />
make<br />
make install<br />
cd ../</p>
<p>ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la<br />
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so<br />
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4<br />
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8<br />
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a<br />
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la<br />
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so<br />
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2<br />
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1</p>
<p>tar zxvf mcrypt-2.6.8.tar.gz<br />
cd mcrypt-2.6.8/<br />
/sbin/ldconfig<br />
./configure<br />
make<br />
make install<br />
cd ../</p>
<p>2、编译安装MySQL 5.1.38</p>
<p class="c">/usr/sbin/groupadd mysql<br />
/usr/sbin/useradd -g mysql mysql<br />
tar zxvf mysql-5.1.38.tar.gz<br />
cd mysql-5.1.38/<br />
./configure &#8211;prefix=/usr/local/webserver/mysql/ &#8211;enable-assembler &#8211;with-extra-charsets=complex &#8211;enable-thread-safe-client &#8211;with-big-tables &#8211;with-readline &#8211;with-ssl &#8211;with-embedded-server &#8211;enable-local-infile &#8211;with-plugins=innobase<br />
make &amp;&amp; make install<br />
chmod +w /usr/local/webserver/mysql<br />
chown -R mysql:mysql /usr/local/webserver/mysql<br />
cd ../</p>
<p>附：以下为附加步骤，如果你想在这台服务器上运行MySQL数据库，则执行以下两步。如果你只是希望让PHP支持MySQL扩展库，能够连接其他服务器上的MySQL数据库，那么，以下两步无需执行。</p>
<p>①、创建MySQL数据库存放目录</p>
<p class="c">mkdir -p /data0/mysql/3306/data/<br />
chown -R mysql:mysql /data0/mysql/</p>
<p>②、以mysql用户帐号的身份建立数据表：</p>
<p class="c">/usr/local/webserver/mysql/bin/mysql_install_db &#8211;basedir=/usr/local/webserver/mysql &#8211;datadir=/data0/mysql/3306/data &#8211;user=mysql</p>
<p>③、创建my.cnf配置文件：</p>
<p class="c">vi /data0/mysql/3306/my.cnf</p>
<p>输入以下内容：</p>
<p class="c">[client]<br />
default-character-set = utf8<br />
port    = 3306<br />
socket  = /tmp/mysql.sock</p>
<p>[mysql]<br />
prompt=”(\u:blog.s135.com:)[\d]&gt; ”<br />
no-auto-rehash</p>
<p>[mysqld]<br />
#default-character-set = utf8<br />
user    = mysql<br />
port    = 3306<br />
socket  = /tmp/mysql.sock<br />
basedir = /usr/local/webserver/mysql<br />
datadir = /data0/mysql/3306/data<br />
open_files_limit    = 10240<br />
back_log = 600<br />
max_connections = 3000<br />
max_connect_errors = 6000<br />
table_cache = 614<br />
external-locking = FALSE<br />
max_allowed_packet = 32M<br />
sort_buffer_size = 2M<br />
join_buffer_size = 2M<br />
thread_cache_size = 300<br />
thread_concurrency = 8<br />
query_cache_size = 32M<br />
query_cache_limit = 2M<br />
query_cache_min_res_unit = 2k<br />
default-storage-engine = MyISAM<br />
default_table_type = MyISAM<br />
thread_stack = 192K<br />
transaction_isolation = READ-COMMITTED<br />
tmp_table_size = 246M<br />
max_heap_table_size = 246M<br />
long_query_time = 1<br />
log_long_format<br />
log-bin = /data0/mysql/3306/binlog<br />
binlog_cache_size = 4M<br />
binlog_format = MIXED<br />
max_binlog_cache_size = 8M<br />
max_binlog_size = 512M<br />
expire_logs_days = 7<br />
key_buffer_size = 256M<br />
read_buffer_size = 1M<br />
read_rnd_buffer_size = 16M<br />
bulk_insert_buffer_size = 64M<br />
myisam_sort_buffer_size = 128M<br />
myisam_max_sort_file_size = 10G<br />
myisam_max_extra_sort_file_size = 10G<br />
myisam_repair_threads = 1<br />
myisam_recover</p>
<p>skip-name-resolve<br />
master-connect-retry = 10<br />
slave-skip-errors = 1032,1062,126,1114,1146,1048,1396</p>
<p>server-id = 1</p>
<p>innodb_additional_mem_pool_size = 16M<br />
innodb_buffer_pool_size = 2048M<br />
innodb_data_file_path = ibdata1:1024M:autoextend<br />
innodb_file_io_threads = 4<br />
innodb_thread_concurrency = 8<br />
innodb_flush_log_at_trx_commit = 2<br />
innodb_log_buffer_size = 16M<br />
innodb_log_file_size = 128M<br />
innodb_log_files_in_group = 3<br />
innodb_max_dirty_pages_pct = 90<br />
innodb_lock_wait_timeout = 120<br />
innodb_file_per_table = 0<br />
[mysqldump]<br />
quick<br />
max_allowed_packet = 32M</p>
<p>④、创建管理MySQL数据库的shell脚本：</p>
<p class="c">vi /data0/mysql/3306/mysql</p>
<p>输入以下内容（这里的用户名admin和密码12345678接下来的步骤会创建）：</p>
<p class="c">#!/bin/sh</p>
<p>mysql_port=3306<br />
mysql_username=”admin”<br />
mysql_password=”12345678&#8243;</p>
<p>function_start_mysql()<br />
{<br />
printf “Starting MySQL&#8230;\n”<br />
/bin/sh /usr/local/webserver/mysql/bin/mysqld_safe &#8211;defaults-file=/data0/mysql/${mysql_port}/my.cnf 2&gt;&amp;1 &gt; /dev/null &amp;<br />
}</p>
<p>function_stop_mysql()<br />
{<br />
printf “Stoping MySQL&#8230;\n”<br />
/usr/local/webserver/mysql/bin/mysqladmin -u ${mysql_username} -p${mysql_password} -S /tmp/mysql.sock shutdown<br />
}</p>
<p>function_restart_mysql()<br />
{<br />
printf “Restarting MySQL&#8230;\n”<br />
function_stop_mysql<br />
sleep 5<br />
function_start_mysql<br />
}</p>
<p>function_kill_mysql()<br />
{<br />
kill -9 $(ps -ef | grep &#8216;bin/mysqld_safe&#8217; | grep ${mysql_port} | awk &#8216;{printf $2}&#8217;)<br />
kill -9 $(ps -ef | grep &#8216;libexec/mysqld&#8217; | grep ${mysql_port} | awk &#8216;{printf $2}&#8217;)<br />
}</p>
<p>if [ "$1" = "start" ]; then<br />
function_start_mysql<br />
elif [ "$1" = "stop" ]; then<br />
function_stop_mysql<br />
elif [ "$1" = "restart" ]; then<br />
function_restart_mysql<br />
elif [ "$1" = "kill" ]; then<br />
function_kill_mysql<br />
else<br />
printf “Usage: /data0/mysql/${mysql_port}/mysql {start|stop|restart|kill}\n”<br />
fi</p>
<p>⑤、赋予shell脚本可执行权限：</p>
<p class="c">chmod +x /data0/mysql/3306/mysql</p>
<p>⑥、启动MySQL：</p>
<p class="c">/data0/mysql/3306/mysql start</p>
<p>⑦、通过命令行登录管理MySQL服务器（提示输入密码时直接回车）：</p>
<p class="c">/usr/local/webserver/mysql/bin/mysql -u root -p -S /tmp/mysql.sock</p>
<p>⑧、输入以下SQL语句，创建一个具有root权限的用户（admin）和密码（12345678）：</p>
<p class="c">GRANT ALL PRIVILEGES ON *.* TO &#8216;admin&#8217;@'localhost&#8217; IDENTIFIED BY &#8217;12345678&#8242;;<br />
GRANT ALL PRIVILEGES ON *.* TO &#8216;admin&#8217;@&#8217;127.0.0.1&#8242; IDENTIFIED BY &#8217;12345678&#8242;;</p>
<p>⑨、（可选）停止MySQL：</p>
<p class="c">/data0/mysql/3306/mysql stop</p>
<p>3、编译安装PHP（FastCGI模式）</p>
<p class="c">tar zxvf php-5.2.10.tar.gz<br />
gzip -cd php-5.2.10-fpm-0.5.11.diff.gz | patch -d php-5.2.10 -p1<br />
cd php-5.2.10/<br />
./configure &#8211;prefix=/usr/local/webserver/php &#8211;with-config-file-path=/usr/local/webserver/php/etc &#8211;with-mysql=/usr/local/webserver/mysql &#8211;with-mysqli=/usr/local/webserver/mysql/bin/mysql_config &#8211;with-iconv-dir=/usr/local &#8211;with-freetype-dir &#8211;with-jpeg-dir &#8211;with-png-dir &#8211;with-zlib &#8211;with-libxml-dir=/usr &#8211;enable-xml &#8211;disable-rpath &#8211;enable-discard-path &#8211;enable-safe-mode &#8211;enable-bcmath &#8211;enable-shmop &#8211;enable-sysvsem &#8211;enable-inline-optimization &#8211;with-curl &#8211;with-curlwrappers &#8211;enable-mbregex &#8211;enable-fastcgi &#8211;enable-fpm &#8211;enable-force-cgi-redirect &#8211;enable-mbstring &#8211;with-mcrypt &#8211;with-gd &#8211;enable-gd-native-ttf &#8211;with-openssl &#8211;with-mhash &#8211;enable-pcntl &#8211;enable-sockets &#8211;with-ldap &#8211;with-ldap-sasl &#8211;with-xmlrpc &#8211;enable-zip &#8211;enable-soap &#8211;without-pear<br />
make ZEND_EXTRA_LIBS=&#8217;-liconv&#8217;<br />
make install<br />
cp php.ini-dist /usr/local/webserver/php/etc/php.ini<br />
cd ../<br />
curl http://pear.php.net/go-pear | /usr/local/webserver/php/bin/php</p>
<p>4、编译安装PHP5扩展模块</p>
<p class="c">tar zxvf memcache-2.2.5.tgz<br />
cd memcache-2.2.5/<br />
/usr/local/webserver/php/bin/phpize<br />
./configure &#8211;with-php-config=/usr/local/webserver/php/bin/php-config<br />
make<br />
make install<br />
cd ../</p>
<p>tar jxvf eaccelerator-0.9.5.3.tar.bz2<br />
cd eaccelerator-0.9.5.3/<br />
/usr/local/webserver/php/bin/phpize<br />
./configure &#8211;enable-eaccelerator=shared &#8211;with-php-config=/usr/local/webserver/php/bin/php-config<br />
make<br />
make install<br />
cd ../</p>
<p>tar zxvf PDO_MYSQL-1.0.2.tgz<br />
cd PDO_MYSQL-1.0.2/<br />
/usr/local/webserver/php/bin/phpize<br />
./configure &#8211;with-php-config=/usr/local/webserver/php/bin/php-config &#8211;with-pdo-mysql=/usr/local/webserver/mysql<br />
make<br />
make install<br />
cd ../</p>
<p>tar zxvf ImageMagick.tar.gz<br />
cd ImageMagick-6.5.1-2/<br />
./configure<br />
make<br />
make install<br />
cd ../</p>
<p>tar zxvf imagick-2.2.2.tgz<br />
cd imagick-2.2.2/<br />
/usr/local/webserver/php/bin/phpize<br />
./configure &#8211;with-php-config=/usr/local/webserver/php/bin/php-config<br />
make<br />
make install<br />
cd ../</p>
<p>5、修改php.ini文件<br />
<strong>手工修改：</strong>查找/usr/local/webserver/php/etc/php.ini中的extension_dir = “./”<br />
修改为extension_dir = “/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/”<br />
并在此行后增加以下几行，然后保存：<br />
extension = “memcache.so”<br />
extension = “pdo_mysql.so”<br />
extension = “imagick.so”</p>
<p>再查找output_buffering = Off<br />
修改为output_buffering = On</p>
<p><strong>自动修改：</strong>若嫌手工修改麻烦，可执行以下shell命令，自动完成对php.ini文件的修改：</p>
<p class="c">sed -i &#8216;s#extension_dir = “./”#extension_dir = “/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/”\nextension = “memcache.so”\nextension = “pdo_mysql.so”\nextension = “imagick.so”\n#&#8217; /usr/local/webserver/php/etc/php.ini<br />
sed -i &#8216;s#output_buffering = Off#output_buffering = On#&#8217; /usr/local/webserver/php/etc/php.ini<br />
sed -i “s#; always_populate_raw_post_data = On#always_populate_raw_post_data = On#g” /usr/local/webserver/php/etc/php.ini</p>
<p>6、配置eAccelerator加速PHP：</p>
<p class="c">mkdir -p /usr/local/webserver/eaccelerator_cache<br />
vi /usr/local/webserver/php/etc/php.ini</p>
<p>按shift+g键跳到配置文件的最末尾，加上以下配置信息：</p>
<p class="c">[eaccelerator]<br />
zend_extension=”/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so”<br />
eaccelerator.shm_size=”64&#8243;<br />
eaccelerator.cache_dir=”/usr/local/webserver/eaccelerator_cache”<br />
eaccelerator.enable=”1&#8243;<br />
eaccelerator.optimizer=”1&#8243;<br />
eaccelerator.check_mtime=”1&#8243;<br />
eaccelerator.debug=”0&#8243;<br />
eaccelerator.filter=”"<br />
eaccelerator.shm_max=”0&#8243;<br />
eaccelerator.shm_ttl=”3600&#8243;<br />
eaccelerator.shm_prune_period=”3600&#8243;<br />
eaccelerator.shm_only=”0&#8243;<br />
eaccelerator.compress=”1&#8243;<br />
eaccelerator.compress_level=”9&#8243;</p>
<p>7、创建www用户和组，以及供blog.s135.com和www.s135.com两个虚拟主机使用的目录：</p>
<p class="c">/usr/sbin/groupadd www<br />
/usr/sbin/useradd -g www www<br />
mkdir -p /data0/htdocs/blog<br />
chmod +w /data0/htdocs/blog<br />
chown -R www:www /data0/htdocs/blog<br />
mkdir -p /data0/htdocs/www<br />
chmod +w /data0/htdocs/www<br />
chown -R www:www /data0/htdocs/www</p>
<p>8、创建php-fpm配置文件（php-fpm是为PHP打的一个FastCGI管理补丁，可以平滑变更php.ini配置而无需重启php-cgi）：<br />
在/usr/local/webserver/php/etc/目录中创建php-fpm.conf文件：</p>
<p class="c">rm -f /usr/local/webserver/php/etc/php-fpm.conf<br />
vi /usr/local/webserver/php/etc/php-fpm.conf</p>
<p>输入以下内容（如果您安装 Nginx + PHP 用于程序调试，请将以下的&lt;value name=”display_errors”&gt;0&lt;/value&gt;改为&lt;value name=”display_errors”&gt;1&lt;/value&gt;，以便显示PHP错误信息，否则，Nginx 会报状态为500的空白错误页）：</p>
<div class="xml">&lt;?xml version=”1.0&#8243; ?&gt;<br />
&lt;configuration&gt;All relative paths in this config are relative to php&#8217;s install prefix&lt;section name=”global_options”&gt;</p>
<p>Pid file<br />
&lt;value name=”pid_file”&gt;/usr/local/webserver/php/logs/php-fpm.pid&lt;/value&gt;</p>
<p>Error log file<br />
&lt;value name=”error_log”&gt;/usr/local/webserver/php/logs/php-fpm.log&lt;/value&gt;</p>
<p>Log level<br />
&lt;value name=”log_level”&gt;notice&lt;/value&gt;</p>
<p>When this amount of php processes exited with SIGSEGV or SIGBUS &#8230;<br />
&lt;value name=”emergency_restart_threshold”&gt;10&lt;/value&gt;</p>
<p>&#8230; in a less than this interval of time, a graceful restart will be initiated.<br />
Useful to work around accidental curruptions in accelerator&#8217;s shared memory.<br />
&lt;value name=”emergency_restart_interval”&gt;1m&lt;/value&gt;</p>
<p>Time limit on waiting child&#8217;s reaction on signals from master<br />
&lt;value name=”process_control_timeout”&gt;5s&lt;/value&gt;</p>
<p>Set to &#8216;no&#8217; to debug fpm<br />
&lt;value name=”daemonize”&gt;yes&lt;/value&gt;</p>
<p>&lt;/section&gt;</p>
<p>&lt;workers&gt;</p>
<p>&lt;section name=”pool”&gt;</p>
<p>Name of pool. Used in logs and stats.<br />
&lt;value name=”name”&gt;default&lt;/value&gt;</p>
<p>Address to accept fastcgi requests on.<br />
Valid syntax is &#8216;ip.ad.re.ss:port&#8217; or just &#8216;port&#8217; or &#8216;/path/to/unix/socket&#8217;<br />
&lt;value name=”listen_address”&gt;127.0.0.1:9000&lt;/value&gt;</p>
<p>&lt;value name=”listen_options”&gt;</p>
<p>Set listen(2) backlog<br />
&lt;value name=”backlog”&gt;-1&lt;/value&gt;</p>
<p>Set permissions for unix socket, if one used.<br />
In Linux read/write permissions must be set in order to allow connections from web server.<br />
Many BSD-derrived systems allow connections regardless of permissions.<br />
&lt;value name=”owner”&gt;&lt;/value&gt;<br />
&lt;value name=”group”&gt;&lt;/value&gt;<br />
&lt;value name=”mode”&gt;0666&lt;/value&gt;<br />
&lt;/value&gt;</p>
<p>Additional php.ini defines, specific to this pool of workers.<br />
&lt;value name=”php_defines”&gt;<br />
&lt;value name=”sendmail_path”&gt;/usr/sbin/sendmail -t -i&lt;/value&gt;<br />
&lt;value name=”display_errors”&gt;1&lt;/value&gt;<br />
&lt;/value&gt;</p>
<p>Unix user of processes<br />
&lt;value name=”user”&gt;www&lt;/value&gt;</p>
<p>Unix group of processes<br />
&lt;value name=”group”&gt;www&lt;/value&gt;</p>
<p>Process manager settings<br />
&lt;value name=”pm”&gt;</p>
<p>Sets style of controling worker process count.<br />
Valid values are &#8216;static&#8217; and &#8216;apache-like&#8217;<br />
&lt;value name=”style”&gt;static&lt;/value&gt;</p>
<p>Sets the limit on the number of simultaneous requests that will be served.<br />
Equivalent to Apache MaxClients directive.<br />
Equivalent to PHP_FCGI_CHILDREN environment in original php.fcgi<br />
Used with any pm_style.<br />
&lt;value name=”max_children”&gt;128&lt;/value&gt;</p>
<p>Settings group for &#8216;apache-like&#8217; pm style<br />
&lt;value name=”apache_like”&gt;</p>
<p>Sets the number of server processes created on startup.<br />
Used only when &#8216;apache-like&#8217; pm_style is selected<br />
&lt;value name=”StartServers”&gt;20&lt;/value&gt;</p>
<p>Sets the desired minimum number of idle server processes.<br />
Used only when &#8216;apache-like&#8217; pm_style is selected<br />
&lt;value name=”MinSpareServers”&gt;5&lt;/value&gt;</p>
<p>Sets the desired maximum number of idle server processes.<br />
Used only when &#8216;apache-like&#8217; pm_style is selected<br />
&lt;value name=”MaxSpareServers”&gt;35&lt;/value&gt;</p>
<p>&lt;/value&gt;</p>
<p>&lt;/value&gt;</p>
<p>The timeout (in seconds) for serving a single request after which the worker process will be terminated<br />
Should be used when &#8216;max_execution_time&#8217; ini option does not stop script execution for some reason<br />
&#8217;0s&#8217; means &#8216;off&#8217;<br />
&lt;value name=”request_terminate_timeout”&gt;0s&lt;/value&gt;</p>
<p>The timeout (in seconds) for serving of single request after which a php backtrace will be dumped to slow.log file<br />
&#8217;0s&#8217; means &#8216;off&#8217;<br />
&lt;value name=”request_slowlog_timeout”&gt;0s&lt;/value&gt;</p>
<p>The log file for slow requests<br />
&lt;value name=”slowlog”&gt;logs/slow.log&lt;/value&gt;</p>
<p>Set open file desc rlimit<br />
&lt;value name=”rlimit_files”&gt;65535&lt;/value&gt;</p>
<p>Set max core size rlimit<br />
&lt;value name=”rlimit_core”&gt;0&lt;/value&gt;</p>
<p>Chroot to this directory at the start, absolute path<br />
&lt;value name=”chroot”&gt;&lt;/value&gt;</p>
<p>Chdir to this directory at the start, absolute path<br />
&lt;value name=”chdir”&gt;&lt;/value&gt;</p>
<p>Redirect workers&#8217; stdout and stderr into main error log.<br />
If not set, they will be redirected to /dev/null, according to FastCGI specs<br />
&lt;value name=”catch_workers_output”&gt;yes&lt;/value&gt;</p>
<p>How much requests each process should execute before respawn.<br />
Useful to work around memory leaks in 3rd party libraries.<br />
For endless request processing please specify 0<br />
Equivalent to PHP_FCGI_MAX_REQUESTS<br />
&lt;value name=”max_requests”&gt;102400&lt;/value&gt;</p>
<p>Comma separated list of ipv4 addresses of FastCGI clients that allowed to connect.<br />
Equivalent to FCGI_WEB_SERVER_ADDRS environment in original php.fcgi (5.2.2+)<br />
Makes sense only with AF_INET listening socket.<br />
&lt;value name=”allowed_clients”&gt;127.0.0.1&lt;/value&gt;</p>
<p>Pass environment variables like LD_LIBRARY_PATH<br />
All $VARIABLEs are taken from current environment<br />
&lt;value name=”environment”&gt;<br />
&lt;value name=”HOSTNAME”&gt;$HOSTNAME&lt;/value&gt;<br />
&lt;value name=”PATH”&gt;/usr/local/bin:/usr/bin:/bin&lt;/value&gt;<br />
&lt;value name=”TMP”&gt;/tmp&lt;/value&gt;<br />
&lt;value name=”TMPDIR”&gt;/tmp&lt;/value&gt;<br />
&lt;value name=”TEMP”&gt;/tmp&lt;/value&gt;<br />
&lt;value name=”OSTYPE”&gt;$OSTYPE&lt;/value&gt;<br />
&lt;value name=”MACHTYPE”&gt;$MACHTYPE&lt;/value&gt;<br />
&lt;value name=”MALLOC_CHECK_”&gt;2&lt;/value&gt;<br />
&lt;/value&gt;</p>
<p>&lt;/section&gt;</p>
<p>&lt;/workers&gt;</p>
<p>&lt;/configuration&gt;</p>
</div>
<p>9、启动php-cgi进程，监听127.0.0.1的9000端口，进程数为200（如果服务器内存小于3GB，可以只开启64个进程），用户为www：</p>
<p class="c">ulimit -SHn 65535<br />
/usr/local/webserver/php/sbin/php-fpm start</p>
<p>注：/usr/local/webserver/php/sbin/php-fpm还有其他参数，包括：start|stop|quit|restart|reload|logrotate，修改php.ini后不重启php-cgi，重新加载配置文件使用reload。</p>
<p><strong>三、安装Nginx 0.8.15</strong><br />
1、安装Nginx所需的pcre库：</p>
<p class="c">tar zxvf pcre-7.9.tar.gz<br />
cd pcre-7.9/<br />
./configure<br />
make &amp;&amp; make install<br />
cd ../</p>
<p>2、安装Nginx</p>
<p class="c">tar zxvf nginx-0.8.15.tar.gz<br />
cd nginx-0.8.15/<br />
./configure &#8211;user=www &#8211;group=www &#8211;prefix=/usr/local/webserver/nginx &#8211;with-http_stub_status_module &#8211;with-http_ssl_module<br />
make &amp;&amp; make install<br />
cd ../</p>
<p>3、创建Nginx日志目录</p>
<p class="c">mkdir -p /data1/logs<br />
chmod +w /data1/logs<br />
chown -R www:www /data1/logs</p>
<p>4、创建Nginx配置文件<br />
①、在/usr/local/webserver/nginx/conf/目录中创建nginx.conf文件：</p>
<p class="c">rm -f /usr/local/webserver/nginx/conf/nginx.conf<br />
vi /usr/local/webserver/nginx/conf/nginx.conf</p>
<p>输入以下内容：</p>
<p class="c">user  www www;<br />
worker_processes 8;<br />
error_log  /data1/logs/nginx_error.log  crit;<br />
pid        /usr/local/webserver/nginx/nginx.pid;</p>
<p>#Specifies the value for maximum file descriptors that can be opened by this process.<br />
worker_rlimit_nofile 65535;</p>
<p>events<br />
{<br />
use epoll;<br />
worker_connections 65535;<br />
}</p>
<p>http<br />
{<br />
include       mime.types;<br />
default_type  application/octet-stream;</p>
<p>#charset  gb2312;</p>
<p>server_names_hash_bucket_size 128;<br />
client_header_buffer_size 32k;<br />
large_client_header_buffers 4 32k;<br />
client_max_body_size 8m;</p>
<p>sendfile on;<br />
tcp_nopush     on;</p>
<p>keepalive_timeout 60;</p>
<p>tcp_nodelay on;</p>
<p>fastcgi_connect_timeout 300;<br />
fastcgi_send_timeout 300;<br />
fastcgi_read_timeout 300;<br />
fastcgi_buffer_size 64k;<br />
fastcgi_buffers 4 64k;<br />
fastcgi_busy_buffers_size 128k;<br />
fastcgi_temp_file_write_size 128k;</p>
<p>gzip on;<br />
gzip_min_length  1k;<br />
gzip_buffers     4 16k;<br />
gzip_http_version 1.0;<br />
gzip_comp_level 2;<br />
gzip_types       text/plain application/x-javascript text/css application/xml;<br />
gzip_vary on;</p>
<p>#limit_zone  crawler  $binary_remote_addr  10m;</p>
<p>server<br />
{<br />
listen       80;<br />
server_name  blog.s135.com;<br />
index index.html index.htm index.php;<br />
root  /data0/htdocs/blog;</p>
<p>#limit_conn   crawler  20;</p>
<p>location ~ .*\.(php|php5)?$<br />
{<br />
#fastcgi_pass  unix:/tmp/php-cgi.sock;<br />
fastcgi_pass  127.0.0.1:9000;<br />
fastcgi_index index.php;<br />
include fcgi.conf;<br />
}</p>
<p>location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$<br />
{<br />
expires      30d;<br />
}</p>
<p>location ~ .*\.(js|css)?$<br />
{<br />
expires      1h;<br />
}</p>
<p>log_format  access  &#8217;$remote_addr &#8211; $remote_user [$time_local] “$request” &#8216;<br />
&#8216;$status $body_bytes_sent “$http_referer” &#8216;<br />
&#8216;”$http_user_agent” $http_x_forwarded_for&#8217;;<br />
access_log  /data1/logs/access.log  access;<br />
}</p>
<p>server<br />
{<br />
listen       80;<br />
server_name  www.s135.com;<br />
index index.html index.htm index.php;<br />
root  /data0/htdocs/www;</p>
<p>location ~ .*\.(php|php5)?$<br />
{<br />
#fastcgi_pass  unix:/tmp/php-cgi.sock;<br />
fastcgi_pass  127.0.0.1:9000;<br />
fastcgi_index index.php;<br />
include fcgi.conf;<br />
}</p>
<p>log_format  wwwlogs  &#8217;$remote_addr &#8211; $remote_user [$time_local] “$request” &#8216;<br />
&#8216;$status $body_bytes_sent “$http_referer” &#8216;<br />
&#8216;”$http_user_agent” $http_x_forwarded_for&#8217;;<br />
access_log  /data1/logs/wwwlogs.log  wwwlogs;<br />
}</p>
<p>server<br />
{<br />
listen  80;<br />
server_name  status.blog.s135.com;</p>
<p>location / {<br />
stub_status on;<br />
access_log   off;<br />
}<br />
}<br />
}</p>
<p>②、在/usr/local/webserver/nginx/conf/目录中创建fcgi.conf文件：</p>
<p class="c">vi /usr/local/webserver/nginx/conf/fcgi.conf</p>
<p>输入以下内容：</p>
<p class="c">fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;<br />
fastcgi_param  SERVER_SOFTWARE    nginx;</p>
<p>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;</p>
<p>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;</p>
<p>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;</p>
<p># PHP only, required if PHP was built with &#8211;enable-force-cgi-redirect<br />
fastcgi_param  REDIRECT_STATUS    200;</p>
<p>5、启动Nginx</p>
<p class="c">ulimit -SHn 65535<br />
/usr/local/webserver/nginx/sbin/nginx</p>
<p><strong>四、配置开机自动启动Nginx + PHP</strong></p>
<p class="c">vi /etc/rc.local</p>
<p>在末尾增加以下内容：</p>
<p class="c">ulimit -SHn 65535<br />
/usr/local/webserver/php/sbin/php-fpm start<br />
/usr/local/webserver/nginx/sbin/nginx</p>
<p><strong>五、优化Linux内核参数</strong></p>
<p class="c">vi /etc/sysctl.conf</p>
<p>在末尾增加以下内容：</p>
<p class="c"># Add<br />
net.ipv4.tcp_max_syn_backlog = 65536<br />
net.core.netdev_max_backlog =  32768<br />
net.core.somaxconn = 32768</p>
<p>net.core.wmem_default = 8388608<br />
net.core.rmem_default = 8388608<br />
net.core.rmem_max = 16777216<br />
net.core.wmem_max = 16777216</p>
<p>net.ipv4.tcp_timestamps = 0<br />
net.ipv4.tcp_synack_retries = 2<br />
net.ipv4.tcp_syn_retries = 2</p>
<p>net.ipv4.tcp_tw_recycle = 1<br />
#net.ipv4.tcp_tw_len = 1<br />
net.ipv4.tcp_tw_reuse = 1</p>
<p>net.ipv4.tcp_mem = 94500000 915000000 927000000<br />
net.ipv4.tcp_max_orphans = 3276800</p>
<p>#net.ipv4.tcp_fin_timeout = 30<br />
#net.ipv4.tcp_keepalive_time = 120<br />
net.ipv4.ip_local_port_range = 1024  65535</p>
<p>使配置立即生效：</p>
<p class="c">/sbin/sysctl -p</p>
<p><strong>六、在不停止Nginx服务的情况下平滑变更Nginx配置</strong><br />
1、修改/usr/local/webserver/nginx/conf/nginx.conf配置文件后，请执行以下命令检查配置文件是否正确：</p>
<p class="c">/usr/local/webserver/nginx/sbin/nginx -t</p>
<p>如果屏幕显示以下两行信息，说明配置文件正确：<br />
the configuration file /usr/local/webserver/nginx/conf/nginx.conf syntax is ok<br />
the configuration file /usr/local/webserver/nginx/conf/nginx.conf was tested successfully</p>
<p>2、这时，输入以下命令查看Nginx主进程号：</p>
<p class="c">ps -ef | grep “nginx: master process” | grep -v “grep” | awk -F &#8216; &#8216; &#8216;{print $2}&#8217;</p>
<p>屏幕显示的即为Nginx主进程号，例如：<br />
6302<br />
这时，执行以下命令即可使修改过的Nginx配置文件生效：</p>
<p class="c">kill -HUP 6302</p>
<p>或者无需这么麻烦，找到Nginx的Pid文件：</p>
<p class="c">kill -HUP `cat /usr/local/webserver/nginx/nginx.pid`</p>
<p><strong>七、编写每天定时切割Nginx日志的脚本</strong><br />
1、创建脚本/usr/local/webserver/nginx/sbin/cut_nginx_log.sh</p>
<p class="c">vi /usr/local/webserver/nginx/sbin/cut_nginx_log.sh</p>
<p>输入以下内容：</p>
<p class="c">#!/bin/bash<br />
# This script run at 00:00</p>
<p># The Nginx logs path<br />
logs_path=”/usr/local/webserver/nginx/logs/”</p>
<p>mkdir -p ${logs_path}$(date -d “yesterday” +”%Y”)/$(date -d “yesterday” +”%m”)/<br />
mv ${logs_path}access.log ${logs_path}$(date -d “yesterday” +”%Y”)/$(date -d “yesterday” +”%m”)/access_$(date -d “yesterday” +”%Y%m%d”).log<br />
kill -USR1 `cat /usr/local/webserver/nginx/nginx.pid`</p>
<p>2、设置crontab，每天凌晨00:00切割nginx访问日志</p>
<p class="c">crontab -e</p>
<p>输入以下内容：</p>
<p class="c">00 00 * * * /bin/bash  /usr/local/webserver/nginx/sbin/cut_nginx_log.sh</p>
<p><strong>附：文章修改历史</strong></p>
<p>● [2009年05月06日] [Version 5.0] 在4.14版本的基础上重新撰写本文，支持PHP 5.2.9，增加MySQL配置过程</p>
<p>● [2009年05月10日] [Version 5.1] 增加压力测试方法。</p>
<p>● [2009年05月20日] [Version 5.2] Nginx升级到0.7.58版本；PHP编译选项增加：&#8211;with-xmlrpc &#8211;enable-zip。</p>
<p>● [2009年06月10日] [Version 5.3] Nginx升级到0.7.59版本；MySQL升级到5.1.35版本。</p>
<p>● [2009年06月26日] [Version 5.4] Nginx升级到0.7.61版本；PHP升级到5.2.10版本；PCRE升级到7.9版本；PHP增加soap扩展；关闭了PHP的PEAR；优化sysctl配置。</p>
<p>● [2009年09月18日] [Version 5.5] Nginx升级到0.8.15版本；PCRE升级到7.9版本；解决PHP 5.2.10 的PEAR问题。</p>

	标签：<a href="http://www.zfkun.com/tag/apache" title="apache" rel="tag">apache</a>, <a href="http://www.zfkun.com/tag/apc" title="apc" rel="tag">apc</a>, <a href="http://www.zfkun.com/tag/centos" title="centos" rel="tag">centos</a>, <a href="http://www.zfkun.com/tag/epoll" title="epoll" rel="tag">epoll</a>, <a href="http://www.zfkun.com/tag/html" title="html" rel="tag">html</a>, <a href="http://www.zfkun.com/tag/http" title="http" rel="tag">http</a>, <a href="http://www.zfkun.com/tag/httpd" title="httpd" rel="tag">httpd</a>, <a href="http://www.zfkun.com/tag/linux" title="linux" rel="tag">linux</a>, <a href="http://www.zfkun.com/tag/memcache" title="memcache" rel="tag">memcache</a>, <a href="http://www.zfkun.com/tag/memcached" title="memcached" rel="tag">memcached</a>, <a href="http://www.zfkun.com/tag/mysql" title="mysql" rel="tag">mysql</a>, <a href="http://www.zfkun.com/tag/nginx" title="nginx" rel="tag">nginx</a>, <a href="http://www.zfkun.com/tag/php" title="PHP" rel="tag">PHP</a>, <a href="http://www.zfkun.com/tag/xcache" title="xcache" rel="tag">xcache</a><br />

	<h4>相关推荐</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.zfkun.com/135.html" title="挑战 hax.tor.hu 申请带ssh的免费php+mysql空间 (2010 年 03 月 19 日)" data-comment="0">挑战 hax.tor.hu 申请带ssh的免费php+mysql空间</a></li>
	<li><a href="http://www.zfkun.com/102.html" title="Windows 下 Nginx + PHP5 的安装与配置 (2010 年 01 月 28 日)" data-comment="0">Windows 下 Nginx + PHP5 的安装与配置</a></li>
	<li><a href="http://www.zfkun.com/39.html" title="基于OpenCV的PHP图像人脸识别技术 (2010 年 01 月 16 日)" data-comment="0">基于OpenCV的PHP图像人脸识别技术</a></li>
	<li><a href="http://www.zfkun.com/223.html" title="动态生成windows快捷方式文件 (2011 年 04 月 02 日)" data-comment="0">动态生成windows快捷方式文件</a></li>
	<li><a href="http://www.zfkun.com/147.html" title="前端资源文件缓存清除一法 (2010 年 11 月 25 日)" data-comment="0">前端资源文件缓存清除一法</a></li>
	<li><a href="http://www.zfkun.com/417.html" title="WordPress Rewrite SEO 之404方式折腾笔记 (2011 年 07 月 17 日)" data-comment="1">WordPress Rewrite SEO 之404方式折腾笔记</a></li>
	<li><a href="http://www.zfkun.com/35.html" title="PHP CURL函数库 (2010 年 01 月 16 日)" data-comment="0">PHP CURL函数库</a></li>
	<li><a href="http://www.zfkun.com/21.html" title="iconv 方法使用 (2010 年 01 月 16 日)" data-comment="0">iconv 方法使用</a></li>
	<li><a href="http://www.zfkun.com/220.html" title="HTML5 canvas 初级入门教程 (2011 年 03 月 20 日)" data-comment="0">HTML5 canvas 初级入门教程</a></li>
	<li><a href="http://www.zfkun.com/html5" title="HTML5 (2011 年 06 月 03 日)" data-comment="0">HTML5</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.zfkun.com/95.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>基于OpenCV的PHP图像人脸识别技术</title>
		<link>http://www.zfkun.com/39.html</link>
		<comments>http://www.zfkun.com/39.html#comments</comments>
		<pubDate>Sat, 16 Jan 2010 15:22:35 +0000</pubDate>
		<dc:creator>影之迷惑</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[facedetect]]></category>
		<category><![CDATA[opencv]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[人脸识别]]></category>
		<category><![CDATA[扩展]]></category>

		<guid isPermaLink="false">http://www.zfkun.com/blog/?p=39</guid>
		<description><![CDATA[写了一个PHP扩展openCV，只封装了两个函数，叫face_detect和face_count。openCV是一个开源的用C/C++开发的计算机图形图像库，非常强大，研究资料很齐全。本文重点是介绍如何使用php来调用其中的局部的功能。人脸侦查技术只是openCV一个应用分支。 <a href="http://www.zfkun.com/39.html">阅读全文 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>写了一个PHP扩展openCV，只封装了两个函数，叫face_detect和face_count。openCV是一个开源的用C/C++开发的计算机图形图像库，非常强大，研究资料很齐全。本文重点是介绍如何使用php来调用其中的局部的功能。人脸侦查技术只是openCV一个应用分支。</p>
<p>1.安装<br />
从源代码编译成一个动态的so文件。</p>
<p>1.1.安装 OpenCV (OpenCV 1.0.0)<br />
下载地址:http://sourceforge.net/project/showfiles.php?group_id=22870&#038;package_id=16948</p>
<pre name="code" class="c">
#tar xvzf OpenCV-1.0.0.tar.gz
#cd opencv-1.0.0
#./configure
#make
#make install
#make check (检查是否安装全部正确)
</pre>
<p>提示： 不要指定安装路径，否则后面编译facedetect会找不到OpenCV的路径。</p>
<p>1.2 安装facedetect<br />
下载地址http://www.xarg.org/download/facedetect-1.0.0.tar.gz</p>
<pre name="code" class="c">
#tar xzvf facedetect-1.0.0.tar.gz
#cd facedetect-1.0.0
#phpize &#038;&#038; ./configure &#038;&#038; make &#038;&#038; make install
</pre>
<p>编译完之后会提示facedetect.so 文件所在的位置。</p>
<p>最后确认在php.ini加入<br />
extension=facedetect.so，重启apache.</p>
<p>2.函数使用<br />
在phpinfo()里检查是否有facedetect这个模块。<br />
从openCV源代码/data/haarcascades/里头取出所有xml文件放在php的执行目录下</p>
<pre name="code" class="php">
//检查有多少个脸型
var_dump(face_count('party.jpeg', haarcascade_frontalface_alt.xml'));
//返回脸型在图片中的位置参数，多个则返回数组
$arr = face_detect('party.jpeg', haarcascade_frontalface_alt2.xml');
print_r($arr);
</pre>
<p>3.应用<br />
结合imagick可以将图片做一下应用。因为 face_detect只返回一个矩形参数，包含x，y坐标和w，h长宽参数。下面是我的一个应用demo</p>
<pre name="code" class="php">
&lt;?php
if($_FILES){
$img = $_FILES['pic']['tmp_name'];
$arr = face_detect($img, 'haarcascade_frontalface_alt2.xml');

//$arr1 = face_detect($img, 'haarcascade_frontalface_alt_tree.xml');

if(is_array($arr1)) $all =array_merge($arr,$arr1);
else $all = $arr;

$im = new Imagick($img);
//$draw =new ImagickDraw();
//$borderColor = new ImagickPixel('red');
//$draw->setFillAlpha(0.0);
//$draw->setStrokeColor  ($borderColor);
//$draw->setStrokeWidth  (1);
if(is_array($all)){
  foreach ($all as $v){
    $im_cl = $im->clone();
    $im_cl->cropImage($v['w'],$v['h'],$v['x'],$v['y']);

    $im_cl->swirlImage(60);
    $im->compositeImage( $im_cl, Imagick::COMPOSITE_OVER , $v['x'], $v['y'] );

    //$draw->rectangle($v['x'],$v['y'],$v['x']+$v['w'],$v['y']+$v['h']);
    //$im->drawimage($draw);

  }
}

  header( "Content-Type: image/png" );
  echo $im;
}else{
?&gt;
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8″ />
<form method="POST" enctype="multipart/form-data">
  人脸识别试验：只支持jpg,png
  上传一张图片
<input type="file" name="pic">
<input type="submit" value="upload">
  </form>

&lt;?
}
?&gt;
</pre>
<p>
参考资料:</p>
<p>http://www.xarg.org/2008/07/face-detection-with-php/</p>
<p>http://www.opencv.org.cn/index.php/首页</p>
<p>http://www.cs.iit.edu/~agam/cs512/lect-notes/opencv-intro/index.html</p>

	标签：<a href="http://www.zfkun.com/tag/facedetect" title="facedetect" rel="tag">facedetect</a>, <a href="http://www.zfkun.com/tag/opencv" title="opencv" rel="tag">opencv</a>, <a href="http://www.zfkun.com/tag/php" title="PHP" rel="tag">PHP</a>, <a href="http://www.zfkun.com/tag/%e4%ba%ba%e8%84%b8%e8%af%86%e5%88%ab" title="人脸识别" rel="tag">人脸识别</a>, <a href="http://www.zfkun.com/tag/%e6%89%a9%e5%b1%95" title="扩展" rel="tag">扩展</a><br />

	<h4>相关推荐</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.zfkun.com/135.html" title="挑战 hax.tor.hu 申请带ssh的免费php+mysql空间 (2010 年 03 月 19 日)" data-comment="0">挑战 hax.tor.hu 申请带ssh的免费php+mysql空间</a></li>
	<li><a href="http://www.zfkun.com/223.html" title="动态生成windows快捷方式文件 (2011 年 04 月 02 日)" data-comment="0">动态生成windows快捷方式文件</a></li>
	<li><a href="http://www.zfkun.com/417.html" title="WordPress Rewrite SEO 之404方式折腾笔记 (2011 年 07 月 17 日)" data-comment="1">WordPress Rewrite SEO 之404方式折腾笔记</a></li>
	<li><a href="http://www.zfkun.com/102.html" title="Windows 下 Nginx + PHP5 的安装与配置 (2010 年 01 月 28 日)" data-comment="0">Windows 下 Nginx + PHP5 的安装与配置</a></li>
	<li><a href="http://www.zfkun.com/35.html" title="PHP CURL函数库 (2010 年 01 月 16 日)" data-comment="0">PHP CURL函数库</a></li>
	<li><a href="http://www.zfkun.com/95.html" title="Nginx 0.8.x + PHP 5.2.10（FastCGI）搭建胜过Apache十倍的Web服务器（第5版） (2010 年 01 月 28 日)" data-comment="0">Nginx 0.8.x + PHP 5.2.10（FastCGI）搭建胜过Apache十倍的Web服务器（第5版）</a></li>
	<li><a href="http://www.zfkun.com/21.html" title="iconv 方法使用 (2010 年 01 月 16 日)" data-comment="0">iconv 方法使用</a></li>
	<li><a href="http://www.zfkun.com/229.html" title="fastcgi_finish_request提速程序执行 (2011 年 04 月 13 日)" data-comment="1">fastcgi_finish_request提速程序执行</a></li>
	<li><a href="http://www.zfkun.com/33.html" title="domdocument::domdocument() expects at least 1 parameter解决办法 (2010 年 01 月 16 日)" data-comment="0">domdocument::domdocument() expects at least 1 parameter解决办法</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.zfkun.com/39.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP CURL函数库</title>
		<link>http://www.zfkun.com/35.html</link>
		<comments>http://www.zfkun.com/35.html#comments</comments>
		<pubDate>Sat, 16 Jan 2010 15:14:39 +0000</pubDate>
		<dc:creator>影之迷惑</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[curl]]></category>

		<guid isPermaLink="false">http://www.zfkun.com/blog/?p=35</guid>
		<description><![CDATA[curl_close — 关闭一个curl会话 curl_copy_handle — 拷贝一个curl连接资源的所有内容和参数 curl_errno — 返回一个包含当前会话错误信息的数字编号 curl_error — 返回一个包含当前会话错误信息的字符串 curl_exec — 执行一个curl会话 curl_getinfo — 获取一个curl连接资源句柄的信息 curl_init — 初始化一个curl会话 curl_multi_add_handle — 向curl批处理会话中添加单独的curl句柄资源 curl_multi_close — 关闭一个批处理句柄资源 curl_multi_exec — 解析一个curl批处理句柄 curl_multi_getcontent — 返回获取的输出的文本流 curl_multi_info_read — 获取当前解析的curl的相关传输信息 curl_multi_init — 初始化一个curl批处理句柄资源 curl_multi_remove_handle &#8230; <a href="http://www.zfkun.com/35.html">阅读全文 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>curl_close — 关闭一个curl会话<br />
curl_copy_handle — 拷贝一个curl连接资源的所有内容和参数<br />
curl_errno — 返回一个包含当前会话错误信息的数字编号<br />
curl_error — 返回一个包含当前会话错误信息的字符串<br />
curl_exec — 执行一个curl会话<br />
curl_getinfo — 获取一个curl连接资源句柄的信息<br />
curl_init — 初始化一个curl会话<br />
curl_multi_add_handle — 向curl批处理会话中添加单独的curl句柄资源<br />
curl_multi_close — 关闭一个批处理句柄资源<br />
curl_multi_exec — 解析一个curl批处理句柄<br />
curl_multi_getcontent — 返回获取的输出的文本流<br />
curl_multi_info_read — 获取当前解析的curl的相关传输信息<br />
curl_multi_init — 初始化一个curl批处理句柄资源<br />
curl_multi_remove_handle — 移除curl批处理句柄资源中的某个句柄资源<br />
curl_multi_select — Get all the sockets associated with the cURL extension, which can then be “selected”<br />
curl_setopt_array — 以数组的形式为一个curl设置会话参数<br />
curl_setopt — 为一个curl设置会话参数<br />
curl_version — 获取curl相关的版本信息<br />
curl_init()函数的作用初始化一个curl会话，curl_init()函数唯一的一个参数是可选的，表示一个url地址。<br />
curl_exec()函数的作用是执行一个curl会话，唯一的参数是curl_init()函数返回的句柄。<br />
curl_close()函数的作用是关闭一个curl会话，唯一的参数是curl_init()函数返回的句柄。</p>
<pre name="code" class="php">
&lt;?php
$ch = curl_init(”http://www.baidu.com/“);
curl_exec($ch);
curl_close($ch);
?&gt;
</pre>
<p>curl_version()函数的作用是获取curl相关的版本信息，curl_version()函数有一个参数，不清楚是做什么的</p>
<pre name="code" class="php">
&lt;?php
print_r(curl_version())
?&gt;
</pre>
<p>curl_getinfo()函数的作用是获取一个curl连接资源句柄的信息，curl_getinfo()函数有两个参数，第一个参数是curl的资源句柄，第二个参数是下面一些常量：</p>
<pre name="code" class="php">
&lt;?php
$ch = curl_init(”http://www.baidu.com/“);
print_r(curl_getinfo($ch));
?&gt;
</pre>
<p>可选的常量包括：<br />
CURLINFO_EFFECTIVE_URL<br />
最后一个有效的url地址<br />
CURLINFO_HTTP_CODE<br />
最后一个收到的HTTP代码<br />
CURLINFO_FILETIME<br />
远程获取文档的时间，如果无法获取，则返回值为“-1”<br />
CURLINFO_TOTAL_TIME<br />
最后一次传输所消耗的时间<br />
CURLINFO_NAMELOOKUP_TIME<br />
名称解析所消耗的时间<br />
CURLINFO_CONNECT_TIME<br />
建立连接所消耗的时间<br />
CURLINFO_PRETRANSFER_TIME<br />
从建立连接到准备传输所使用的时间<br />
CURLINFO_STARTTRANSFER_TIME<br />
从建立连接到传输开始所使用的时间<br />
CURLINFO_REDIRECT_TIME<br />
在事务传输开始前重定向所使用的时间<br />
CURLINFO_SIZE_UPLOAD<br />
上传数据量的总值<br />
CURLINFO_SIZE_DOWNLOAD<br />
下载数据量的总值<br />
CURLINFO_SPEED_DOWNLOAD<br />
平均下载速度<br />
CURLINFO_SPEED_UPLOAD<br />
平均上传速度<br />
CURLINFO_HEADER_SIZE<br />
header部分的大小<br />
CURLINFO_HEADER_OUT<br />
发送请求的字符串<br />
CURLINFO_REQUEST_SIZE<br />
在HTTP请求中有问题的请求的大小<br />
CURLINFO_SSL_VERIFYRESULT<br />
Result of SSL certification verification requested by setting CURLOPT_SSL_VERIFYPEER<br />
CURLINFO_CONTENT_LENGTH_DOWNLOAD<br />
从Content-Length: field中读取的下载内容长度<br />
CURLINFO_CONTENT_LENGTH_UPLOAD<br />
上传内容大小的说明<br />
CURLINFO_CONTENT_TYPE<br />
下载内容的“Content-type”值，NULL表示服务器没有发送有效的“Content-Type: header”</p>
<p>curl_setopt()函数的作用是为一个curl设置会话参数。curl_setopt_array()函数的作用是以数组的形式为一个curl设置会话参数。</p>
<pre name="code" class="php">
&lt;?php
$ch = curl_init();
$fp = fopen(”example_homepage.txt”, “w”);
curl_setopt($ch, CURLOPT_FILE, $fp);
$options = array(
CURLOPT_URL => ‘http://www.baidu.com/’,
CURLOPT_HEADER => false
);
curl_setopt_array($ch, $options);
curl_exec($ch);
curl_close($ch);
fclose($fp);
?&gt;
</pre>
<p>可设置的参数有：<br />
CURLOPT_AUTOREFERER<br />
自动设置header中的referer信息<br />
CURLOPT_BINARYTRANSFER<br />
在启用CURLOPT_RETURNTRANSFER时候将获取数据返回<br />
CURLOPT_COOKIESESSION<br />
启用时curl会仅仅传递一个session cookie，忽略其他的cookie，默认状况下curl会将所有的cookie返回给服务端。session cookie是指那些用来判断服务器端的session是否有效而存在的cookie。<br />
CURLOPT_CRLF<br />
启用时将Unix的换行符转换成回车换行符。<br />
CURLOPT_DNS_USE_GLOBAL_CACHE<br />
启用时会启用一个全局的DNS缓存，此项为线程安全的，并且默认为true。<br />
CURLOPT_FAILONERROR<br />
显示HTTP状态码，默认行为是忽略编号小于等于400的HTTP信息<br />
CURLOPT_FILETIME<br />
启用时会尝试修改远程文档中的信息。结果信息会通过curl_getinfo()函数的CURLINFO_FILETIME选项返回。<br />
CURLOPT_FOLLOWLOCATION<br />
启用时会将服务器服务器返回的“Location:”放在header中递归的返回给服务器，使用CURLOPT_MAXREDIRS可以限定递归返回的数量。<br />
CURLOPT_FORBID_REUSE<br />
在完成交互以后强迫断开连接，不能重用。<br />
CURLOPT_FRESH_CONNECT<br />
强制获取一个新的连接，替代缓存中的连接。<br />
CURLOPT_FTP_USE_EPRT<br />
TRUE to use EPRT (and LPRT) when doing active FTP downloads. Use FALSE to disable EPRT and LPRT and use PORT only.<br />
Added in PHP 5.0.0.<br />
CURLOPT_FTP_USE_EPSV<br />
TRUE to first try an EPSV command for FTP transfers before reverting back to PASV. Set to FALSE to disable EPSV.<br />
CURLOPT_FTPAPPEND<br />
TRUE to append to the remote file instead of overwriting it.<br />
CURLOPT_FTPASCII<br />
An alias of CURLOPT_TRANSFERTEXT. Use that instead.<br />
CURLOPT_FTPLISTONLY<br />
TRUE to only list the names of an FTP directory.<br />
CURLOPT_HEADER<br />
启用时会将头文件的信息作为数据流输出。<br />
CURLOPT_HTTPGET<br />
启用时会设置HTTP的method为GET，因为GET是默认是，所以只在被修改的情况下使用。<br />
CURLOPT_HTTPPROXYTUNNEL<br />
启用时会通过HTTP代理来传输。<br />
CURLOPT_MUTE<br />
讲curl函数中所有修改过的参数恢复默认值。<br />
CURLOPT_NETRC<br />
在连接建立以后，访问~/.netrc文件获取用户名和密码信息连接远程站点。<br />
CURLOPT_NOBODY<br />
启用时将不对HTML中的body部分进行输出。<br />
CURLOPT_NOPROGRESS<br />
启用时关闭curl传输的进度条，此项的默认设置为true<br />
CURLOPT_NOSIGNAL<br />
启用时忽略所有的curl传递给php进行的信号。在SAPI多线程传输时此项被默认打开。<br />
CURLOPT_POST<br />
启用时会发送一个常规的POST请求，类型为：application/x-www-form-urlencoded，就像表单提交的一样。<br />
CURLOPT_PUT<br />
启用时允许HTTP发送文件，必须同时设置CURLOPT_INFILE和CURLOPT_INFILESIZE<br />
CURLOPT_RETURNTRANSFER<br />
讲curl_exec()获取的信息以文件流的形式返回，而不是直接输出。<br />
CURLOPT_SSL_VERIFYPEER<br />
FALSE to stop cURL from verifying the peer’s certificate. Alternate certificates to verify against can be specified with the CURLOPT_CAINFO option or a certificate directory can be specified with the CURLOPT_CAPATH option. CURLOPT_SSL_VERIFYHOST may also need to be TRUE or FALSE if CURLOPT_SSL_VERIFYPEER is disabled (it defaults to 2). TRUE by default as of cURL 7.10. Default bundle installed as of cURL 7.10.<br />
CURLOPT_TRANSFERTEXT<br />
TRUE to use ASCII mode for FTP transfers. For LDAP, it retrieves data in plain text instead of HTML. On Windows systems, it will not set STDOUT to binary mode.<br />
CURLOPT_UNRESTRICTED_AUTH<br />
在使用CURLOPT_FOLLOWLOCATION产生的header中的多个locations中持续追加用户名和密码信息，即使域名已发生改变。<br />
CURLOPT_UPLOAD<br />
启用时允许文件传输<br />
CURLOPT_VERBOSE<br />
启用时会汇报所有的信息，存放在STDERR或指定的CURLOPT_STDERR中<br />
CURLOPT_BUFFERSIZE<br />
每次获取的数据中读入缓存的大小，这个值每次都会被填满。<br />
CURLOPT_CLOSEPOLICY<br />
不是CURLCLOSEPOLICY_LEAST_RECENTLY_USED就是CURLCLOSEPOLICY_OLDEST，还存在另外三个，但是curl暂时还不支持。.<br />
CURLOPT_CONNECTTIMEOUT<br />
在发起连接前等待的时间，如果设置为0，则不等待。</p>
<p>CURLOPT_DNS_CACHE_TIMEOUT<br />
设置在内存中保存DNS信息的时间，默认为120秒。<br />
CURLOPT_FTPSSLAUTH<br />
The FTP authentication method (when is activated): CURLFTPAUTH_SSL (try SSL first), CURLFTPAUTH_TLS (try TLS first), or CURLFTPAUTH_DEFAULT (let cURL decide).<br />
CURLOPT_HTTP_VERSION<br />
设置curl使用的HTTP协议，CURL_HTTP_VERSION_NONE（让curl自己判断），CURL_HTTP_VERSION_1_0（HTTP/1.0），CURL_HTTP_VERSION_1_1（HTTP/1.1）<br />
CURLOPT_HTTPAUTH<br />
使用的HTTP验证方法，可选的值有：CURLAUTH_BASIC，CURLAUTH_DIGEST，CURLAUTH_GSSNEGOTIATE，CURLAUTH_NTLM，CURLAUTH_ANY，CURLAUTH_ANYSAFE，可以使用“|”操作符分隔多个值，curl让服务器选择一个支持最好的值，CURLAUTH_ANY等价于CURLAUTH_BASIC | CURLAUTH_DIGEST | CURLAUTH_GSSNEGOTIATE | CURLAUTH_NTLM，CURLAUTH_ANYSAFE等价于CURLAUTH_DIGEST | CURLAUTH_GSSNEGOTIATE | CURLAUTH_NTLM<br />
CURLOPT_INFILESIZE<br />
设定上传文件的大小<br />
CURLOPT_LOW_SPEED_LIMIT<br />
当传输速度小于CURLOPT_LOW_SPEED_LIMIT时，PHP会根据CURLOPT_LOW_SPEED_TIME来判断是否因太慢而取消传输。<br />
CURLOPT_LOW_SPEED_TIME<br />
The number of seconds the transfer should be below CURLOPT_LOW_SPEED_LIMIT for PHP to consider the transfer too slow and abort.<br />
当传输速度小于CURLOPT_LOW_SPEED_LIMIT时，PHP会根据CURLOPT_LOW_SPEED_TIME来判断是否因太慢而取消传输。<br />
CURLOPT_MAXCONNECTS<br />
允许的最大连接数量，超过是会通过CURLOPT_CLOSEPOLICY决定应该停止哪些连接<br />
CURLOPT_MAXREDIRS<br />
指定最多的HTTP重定向的数量，这个选项是和CURLOPT_FOLLOWLOCATION一起使用的。<br />
CURLOPT_PORT<br />
一个可选的用来指定连接端口的量<br />
CURLOPT_PROXYAUTH<br />
The HTTP authentication method(s) to use for the proxy connection. Use the same bitmasks as described in CURLOPT_HTTPAUTH. For proxy authentication, only CURLAUTH_BASIC and CURLAUTH_NTLM are currently supported.<br />
CURLOPT_PROXYPORT<br />
The port number of the proxy to connect to. This port number can also be set in CURLOPT_PROXY.<br />
CURLOPT_PROXYTYPE<br />
Either CURLPROXY_HTTP (default) or CURLPROXY_SOCKS5.<br />
CURLOPT_RESUME_FROM<br />
在恢复传输时传递一个字节偏移量（用来断点续传）<br />
CURLOPT_SSL_VERIFYHOST<br />
1 to check the existence of a common name in the SSL peer certificate.<br />
2 to check the existence of a common name and also verify that it matches the hostname provided.<br />
CURLOPT_SSLVERSION<br />
The SSL version (2 or 3) to use. By default PHP will try to determine this itself, although in some cases this must be set manually.<br />
CURLOPT_TIMECONDITION<br />
如果在CURLOPT_TIMEVALUE指定的某个时间以后被编辑过，则使用CURL_TIMECOND_IFMODSINCE返回页面，如果没有被修改过，并且CURLOPT_HEADER为true，则返回一个”304 Not Modified”的header，CURLOPT_HEADER为false，则使用CURL_TIMECOND_ISUNMODSINCE，默认值为 CURL_TIMECOND_IFMODSINCE<br />
CURLOPT_TIMEOUT<br />
设置curl允许执行的最长秒数<br />
CURLOPT_TIMEVALUE<br />
设置一个CURLOPT_TIMECONDITION使用的时间戳，在默认状态下使用的是CURL_TIMECOND_IFMODSINCE<br />
CURLOPT_CAINFO<br />
The name of a file holding one or more certificates to verify the peer with. This only makes sense when used in combination with CURLOPT_SSL_VERIFYPEER.<br />
CURLOPT_CAPATH<br />
A directory that holds multiple CA certificates. Use this option alongside CURLOPT_SSL_VERIFYPEER.<br />
CURLOPT_COOKIE<br />
设定HTTP请求中“Set-Cookie:”部分的内容。<br />
CURLOPT_COOKIEFILE<br />
包含cookie信息的文件名称，这个cookie文件可以是Netscape格式或者HTTP风格的header信息。<br />
CURLOPT_COOKIEJAR<br />
连接关闭以后，存放cookie信息的文件名称<br />
CURLOPT_CUSTOMREQUEST<br />
A custom request method to use instead of “GET” or “HEAD” when doing a HTTP request. This is useful for doing “DELETE” or other, more obscure HTTP requests. Valid values are things like “GET”, “POST”, “CONNECT” and so on; i.e. Do not enter a whole HTTP request line here. For instance, entering “GET /index.html HTTP/1.0\r\n\r\n” would be incorrect.<br />
Note: Don’t do this without making sure the server supports the custom request method first.<br />
CURLOPT_EGBSOCKET<br />
Like CURLOPT_RANDOM_FILE, except a filename to an Entropy Gathering Daemon socket.<br />
CURLOPT_ENCODING<br />
header中“Accept-Encoding: ”部分的内容，支持的编码格式为：”identity”，”deflate”，”gzip”。如果设置为空字符串，则表示支持所有的编码格式<br />
CURLOPT_FTPPORT<br />
The value which will be used to get the IP address to use for the FTP “POST” instruction. The “POST” instruction tells the remote server to connect to our specified IP address. The string may be a plain IP address, a hostname, a network interface name (under Unix), or just a plain ‘-’ to use the systems default IP address.<br />
CURLOPT_INTERFACE<br />
在外部网络接口中使用的名称，可以是一个接口名，IP或者主机名。<br />
CURLOPT_KRB4LEVEL<br />
KRB4(Kerberos 4)安全级别的设置，可以是一下几个值之一：”clear”，”safe”，”confidential”，”private”。默认的值为”private”，设置为null的时候表示禁用KRB4，现在KRB4安全仅能在FTP传输中使用。<br />
CURLOPT_POSTFIELDS<br />
在HTTP中的“POST”操作。如果要传送一个文件，需要一个@开头的文件名<br />
CURLOPT_PROXY<br />
设置通过的HTTP代理服务器<br />
CURLOPT_PROXYUSERPWD<br />
连接到代理服务器的，格式为“[username]:[password]”的用户名和密码。<br />
CURLOPT_RANDOM_FILE<br />
设定存放SSL用到的随机数种子的文件名称<br />
CURLOPT_RANGE<br />
设置HTTP传输范围，可以用“X-Y”的形式设置一个传输区间，如果有多个HTTP传输，则使用逗号分隔多个值，形如：”X-Y,N-M”。<br />
CURLOPT_REFERER<br />
设置header中”Referer: ” 部分的值。<br />
CURLOPT_SSL_CIPHER_LIST<br />
A list of ciphers to use for SSL. For example, RC4-SHA and TLSv1 are valid cipher lists.<br />
CURLOPT_SSLCERT<br />
传递一个包含PEM格式证书的字符串。<br />
CURLOPT_SSLCERTPASSWD<br />
传递一个包含使用CURLOPT_SSLCERT证书必需的密码。<br />
CURLOPT_SSLCERTTYPE<br />
The format of the certificate. Supported formats are “PEM” (default), “DER”, and “ENG”.<br />
CURLOPT_SSLENGINE<br />
The identifier for the crypto engine of the private SSL key specified in CURLOPT_SSLKEY.<br />
CURLOPT_SSLENGINE_DEFAULT<br />
The identifier for the crypto engine used for asymmetric crypto operations.<br />
CURLOPT_SSLKEY<br />
The name of a file containing a private SSL key.<br />
CURLOPT_SSLKEYPASSWD<br />
The secret password needed to use the private SSL key specified in CURLOPT_SSLKEY.<br />
Note: Since this option contains a sensitive password, remember to keep the PHP script it is contained within safe.<br />
CURLOPT_SSLKEYTYPE<br />
The key type of the private SSL key specified in CURLOPT_SSLKEY. Supported key types are “PEM” (default), “DER”, and “ENG”.<br />
CURLOPT_URL<br />
需要获取的URL地址，也可以在PHP的curl_init()函数中设置。<br />
CURLOPT_USERAGENT<br />
在HTTP请求中包含一个”user-agent”头的字符串。<br />
CURLOPT_USERPWD<br />
传递一个连接中需要的用户名和密码，格式为：“[username]:[password]”。<br />
CURLOPT_HTTP200ALIASES<br />
设置不再以error的形式来处理HTTP 200的响应，格式为一个数组。<br />
CURLOPT_HTTPHEADER<br />
设置一个header中传输内容的数组。<br />
CURLOPT_POSTQUOTE<br />
An array of FTP commands to execute on the server after the FTP request has been performed.<br />
CURLOPT_QUOTE<br />
An array of FTP commands to execute on the server prior to the FTP request.<br />
CURLOPT_FILE<br />
设置输出文件的位置，值是一个资源类型，默认为STDOUT (浏览器)。<br />
CURLOPT_INFILE<br />
在上传文件的时候需要读取的文件地址，值是一个资源类型。<br />
CURLOPT_STDERR<br />
设置一个错误输出地址，值是一个资源类型，取代默认的STDERR。<br />
CURLOPT_WRITEHEADER<br />
设置header部分内容的写入的文件地址，值是一个资源类型。<br />
CURLOPT_HEADERFUNCTION<br />
设置一个回调函数，这个函数有两个参数，第一个是curl的资源句柄，第二个是输出的header数据。header数据的输出必须依赖这个函数，返回已写入的数据大小。<br />
CURLOPT_PASSWDFUNCTION<br />
设置一个回调函数，有三个参数，第一个是curl的资源句柄，第二个是一个密码提示符，第三个参数是密码长度允许的最大值。返回密码的值。<br />
CURLOPT_READFUNCTION<br />
设置一个回调函数，有两个参数，第一个是curl的资源句柄，第二个是读取到的数据。数据读取必须依赖这个函数。返回读取数据的大小，比如0或者EOF。<br />
CURLOPT_WRITEFUNCTION<br />
设置一个回调函数，有两个参数，第一个是curl的资源句柄，第二个是写入的数据。数据写入必须依赖这个函数。返回精确的已写入数据的大小<br />
curl_copy_handle()函数的作用是拷贝一个curl连接资源的所有内容和参数</p>
<pre name="code" class="php">
&lt;?php
$ch = curl_init(”http://www.baidu.com/“);
$another = curl_copy_handle($ch);
curl_exec($another);
curl_close($another);
?&gt;
</pre>
<p>curl_error()函数的作用是返回一个包含当前会话错误信息的字符串。<br />
curl_errno()函数的作用是返回一个包含当前会话错误信息的数字编号。<br />
curl_multi_init()函数的作用是初始化一个curl批处理句柄资源。<br />
curl_multi_add_handle()函数的作用是向curl批处理会话中添加单独的curl句柄资源。curl_multi_add_handle()函数有两个参数，第一个参数表示一个curl批处理句柄资源，第二个参数表示一个单独的curl句柄资源。<br />
curl_multi_exec()函数的作用是解析一个curl批处理句柄，curl_multi_exec()函数有两个参数，第一个参数表示一个批处理句柄资源，第二个参数是一个引用值的参数，表示剩余需要处理的单个的curl句柄资源数量。<br />
curl_multi_remove_handle() 函数表示移除curl批处理句柄资源中的某个句柄资源，curl_multi_remove_handle()函数有两个参数，第一个参数表示一个 curl批处理句柄资源，第二个参数表示一个单独的curl句柄资源。<br />
curl_multi_close()函数的作用是关闭一个批处理句柄资源。</p>
<pre name="code" class="php">
&lt;?php
$ch1 = curl_init();
$ch2 = curl_init();
curl_setopt($ch1, CURLOPT_URL, “http://www.baidu.com/“);
curl_setopt($ch1, CURLOPT_HEADER, 0);
curl_setopt($ch2, CURLOPT_URL, “http://www.google.com/“);
curl_setopt($ch2, CURLOPT_HEADER, 0);
$mh = curl_multi_init();
curl_multi_add_handle($mh,$ch1);
curl_multi_add_handle($mh,$ch2);
do {
curl_multi_exec($mh,$flag);
} while ($flag > 0);
curl_multi_remove_handle($mh,$ch1);
curl_multi_remove_handle($mh,$ch2);
curl_multi_close($mh);
?&gt;
</pre>
<p>curl_multi_getcontent()函数的作用是在设置了CURLOPT_RETURNTRANSFER的情况下，返回获取的输出的文本流。<br />
curl_multi_info_read()函数的作用是获取当前解析的curl的相关传输信息。<br />
curl_multi_select()<br />
Get all the sockets associated with the cURL extension, which can then be “selected”</p>

	标签：<a href="http://www.zfkun.com/tag/curl" title="curl" rel="tag">curl</a>, <a href="http://www.zfkun.com/tag/php" title="PHP" rel="tag">PHP</a><br />

	<h4>相关推荐</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.zfkun.com/135.html" title="挑战 hax.tor.hu 申请带ssh的免费php+mysql空间 (2010 年 03 月 19 日)" data-comment="0">挑战 hax.tor.hu 申请带ssh的免费php+mysql空间</a></li>
	<li><a href="http://www.zfkun.com/39.html" title="基于OpenCV的PHP图像人脸识别技术 (2010 年 01 月 16 日)" data-comment="0">基于OpenCV的PHP图像人脸识别技术</a></li>
	<li><a href="http://www.zfkun.com/223.html" title="动态生成windows快捷方式文件 (2011 年 04 月 02 日)" data-comment="0">动态生成windows快捷方式文件</a></li>
	<li><a href="http://www.zfkun.com/417.html" title="WordPress Rewrite SEO 之404方式折腾笔记 (2011 年 07 月 17 日)" data-comment="1">WordPress Rewrite SEO 之404方式折腾笔记</a></li>
	<li><a href="http://www.zfkun.com/102.html" title="Windows 下 Nginx + PHP5 的安装与配置 (2010 年 01 月 28 日)" data-comment="0">Windows 下 Nginx + PHP5 的安装与配置</a></li>
	<li><a href="http://www.zfkun.com/95.html" title="Nginx 0.8.x + PHP 5.2.10（FastCGI）搭建胜过Apache十倍的Web服务器（第5版） (2010 年 01 月 28 日)" data-comment="0">Nginx 0.8.x + PHP 5.2.10（FastCGI）搭建胜过Apache十倍的Web服务器（第5版）</a></li>
	<li><a href="http://www.zfkun.com/21.html" title="iconv 方法使用 (2010 年 01 月 16 日)" data-comment="0">iconv 方法使用</a></li>
	<li><a href="http://www.zfkun.com/229.html" title="fastcgi_finish_request提速程序执行 (2011 年 04 月 13 日)" data-comment="1">fastcgi_finish_request提速程序执行</a></li>
	<li><a href="http://www.zfkun.com/33.html" title="domdocument::domdocument() expects at least 1 parameter解决办法 (2010 年 01 月 16 日)" data-comment="0">domdocument::domdocument() expects at least 1 parameter解决办法</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.zfkun.com/35.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>domdocument::domdocument() expects at least 1 parameter解决办法</title>
		<link>http://www.zfkun.com/33.html</link>
		<comments>http://www.zfkun.com/33.html#comments</comments>
		<pubDate>Sat, 16 Jan 2010 15:11:13 +0000</pubDate>
		<dc:creator>影之迷惑</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[document]]></category>
		<category><![CDATA[dom]]></category>
		<category><![CDATA[domxml]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://www.zfkun.com/blog/?p=33</guid>
		<description><![CDATA[问题的解决方法：http://bugs.php.net/bug.php?id=45538 php5 在 windows 下运行时，不需要在 php.ini 里声明 php_domxml.dll，加个分号注释起来就行了。 If you use PHP 5 in windows, you don’t need to declare php_domxml.dll in your php.ini file. so u can give comment in the line php_domxml.dll in your php.ini file. you only &#8230; <a href="http://www.zfkun.com/33.html">阅读全文 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>问题的解决方法：http://bugs.php.net/bug.php?id=45538<br />
php5 在 windows 下运行时，不需要在 php.ini 里声明 php_domxml.dll，加个分号注释起来就行了。</p>
<p>If you use PHP 5 in windows, you don’t need to declare php_domxml.dll in your php.ini file.<br />
so u can give comment in the line php_domxml.dll in your php.ini file.<br />
you only need to comment it out, but do not delete the php_domxml.dll file in the ext directory.</p>

	标签：<a href="http://www.zfkun.com/tag/document" title="document" rel="tag">document</a>, <a href="http://www.zfkun.com/tag/dom" title="dom" rel="tag">dom</a>, <a href="http://www.zfkun.com/tag/domxml" title="domxml" rel="tag">domxml</a>, <a href="http://www.zfkun.com/tag/php" title="PHP" rel="tag">PHP</a>, <a href="http://www.zfkun.com/tag/xml" title="xml" rel="tag">xml</a>, <a href="http://www.zfkun.com/tag/zend" title="zend" rel="tag">zend</a><br />

	<h4>相关推荐</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.zfkun.com/135.html" title="挑战 hax.tor.hu 申请带ssh的免费php+mysql空间 (2010 年 03 月 19 日)" data-comment="0">挑战 hax.tor.hu 申请带ssh的免费php+mysql空间</a></li>
	<li><a href="http://www.zfkun.com/39.html" title="基于OpenCV的PHP图像人脸识别技术 (2010 年 01 月 16 日)" data-comment="0">基于OpenCV的PHP图像人脸识别技术</a></li>
	<li><a href="http://www.zfkun.com/223.html" title="动态生成windows快捷方式文件 (2011 年 04 月 02 日)" data-comment="0">动态生成windows快捷方式文件</a></li>
	<li><a href="http://www.zfkun.com/417.html" title="WordPress Rewrite SEO 之404方式折腾笔记 (2011 年 07 月 17 日)" data-comment="1">WordPress Rewrite SEO 之404方式折腾笔记</a></li>
	<li><a href="http://www.zfkun.com/102.html" title="Windows 下 Nginx + PHP5 的安装与配置 (2010 年 01 月 28 日)" data-comment="0">Windows 下 Nginx + PHP5 的安装与配置</a></li>
	<li><a href="http://www.zfkun.com/109.html" title="Understanding and Solving Internet Explorer Leak Patterns (2010 年 02 月 28 日)" data-comment="0">Understanding and Solving Internet Explorer Leak Patterns</a></li>
	<li><a href="http://www.zfkun.com/35.html" title="PHP CURL函数库 (2010 年 01 月 16 日)" data-comment="0">PHP CURL函数库</a></li>
	<li><a href="http://www.zfkun.com/95.html" title="Nginx 0.8.x + PHP 5.2.10（FastCGI）搭建胜过Apache十倍的Web服务器（第5版） (2010 年 01 月 28 日)" data-comment="0">Nginx 0.8.x + PHP 5.2.10（FastCGI）搭建胜过Apache十倍的Web服务器（第5版）</a></li>
	<li><a href="http://www.zfkun.com/21.html" title="iconv 方法使用 (2010 年 01 月 16 日)" data-comment="0">iconv 方法使用</a></li>
	<li><a href="http://www.zfkun.com/229.html" title="fastcgi_finish_request提速程序执行 (2011 年 04 月 13 日)" data-comment="1">fastcgi_finish_request提速程序执行</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.zfkun.com/33.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iconv 方法使用</title>
		<link>http://www.zfkun.com/21.html</link>
		<comments>http://www.zfkun.com/21.html#comments</comments>
		<pubDate>Sat, 16 Jan 2010 15:00:26 +0000</pubDate>
		<dc:creator>影之迷惑</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[iconv]]></category>
		<category><![CDATA[转码]]></category>

		<guid isPermaLink="false">http://www.zfkun.com/blog/?p=21</guid>
		<description><![CDATA[有时候使用iconv方法转换部分文字的时候可能会出现异常或转换失败的情况，这个时候就得追加一些参数来帮助处理了。 <a href="http://www.zfkun.com/21.html">阅读全文 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>有时候使用iconv方法转换部分文字的时候可能会出现异常或转换失败的情况，这个时候就得追加一些参数来帮助处理了。</p>
<p>string <strong><span style="color: #ff0000;">iconv</span></strong><span style="color: #ff0000;"> </span>( string in_charset, string out_charset, string str )</p>
<p>在 out_charset 参数后追加:</p>
<ul>
<li>“<tt><strong><span style="color: #ff0000;">//TRANSLIT</span></strong>" 程序在转换发生错误时会自动找寻相似的一个或几个字符来代替</tt></li>
<li><tt>"<strong><span style="color: #ff0000;">//IGNORE</span></strong>"  程序会在转换错误时自动跳过忽略当前字符</tt></li>
</ul>
<p>自己这里记录一下。</p>

	标签：<a href="http://www.zfkun.com/tag/iconv" title="iconv" rel="tag">iconv</a>, <a href="http://www.zfkun.com/tag/php" title="PHP" rel="tag">PHP</a>, <a href="http://www.zfkun.com/tag/%e8%bd%ac%e7%a0%81" title="转码" rel="tag">转码</a><br />

	<h4>相关推荐</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.zfkun.com/135.html" title="挑战 hax.tor.hu 申请带ssh的免费php+mysql空间 (2010 年 03 月 19 日)" data-comment="0">挑战 hax.tor.hu 申请带ssh的免费php+mysql空间</a></li>
	<li><a href="http://www.zfkun.com/39.html" title="基于OpenCV的PHP图像人脸识别技术 (2010 年 01 月 16 日)" data-comment="0">基于OpenCV的PHP图像人脸识别技术</a></li>
	<li><a href="http://www.zfkun.com/223.html" title="动态生成windows快捷方式文件 (2011 年 04 月 02 日)" data-comment="0">动态生成windows快捷方式文件</a></li>
	<li><a href="http://www.zfkun.com/417.html" title="WordPress Rewrite SEO 之404方式折腾笔记 (2011 年 07 月 17 日)" data-comment="1">WordPress Rewrite SEO 之404方式折腾笔记</a></li>
	<li><a href="http://www.zfkun.com/102.html" title="Windows 下 Nginx + PHP5 的安装与配置 (2010 年 01 月 28 日)" data-comment="0">Windows 下 Nginx + PHP5 的安装与配置</a></li>
	<li><a href="http://www.zfkun.com/35.html" title="PHP CURL函数库 (2010 年 01 月 16 日)" data-comment="0">PHP CURL函数库</a></li>
	<li><a href="http://www.zfkun.com/95.html" title="Nginx 0.8.x + PHP 5.2.10（FastCGI）搭建胜过Apache十倍的Web服务器（第5版） (2010 年 01 月 28 日)" data-comment="0">Nginx 0.8.x + PHP 5.2.10（FastCGI）搭建胜过Apache十倍的Web服务器（第5版）</a></li>
	<li><a href="http://www.zfkun.com/229.html" title="fastcgi_finish_request提速程序执行 (2011 年 04 月 13 日)" data-comment="1">fastcgi_finish_request提速程序执行</a></li>
	<li><a href="http://www.zfkun.com/33.html" title="domdocument::domdocument() expects at least 1 parameter解决办法 (2010 年 01 月 16 日)" data-comment="0">domdocument::domdocument() expects at least 1 parameter解决办法</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.zfkun.com/21.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

