<?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>沈二铺子</title>
	<atom:link href="http://shen2.cn/feed/" rel="self" type="application/rss+xml" />
	<link>http://shen2.cn</link>
	<description>我是个会写程序的产品经理，但本博只谈技术不谈产品，mysql / nginx / php / html5 / javascript</description>
	<lastBuildDate>Tue, 27 Mar 2012 07:58:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>http header中缺少Content-Type导致$_POST为空</title>
		<link>http://shen2.cn/2012/03/http-header-content-type-post/</link>
		<comments>http://shen2.cn/2012/03/http-header-content-type-post/#comments</comments>
		<pubDate>Tue, 27 Mar 2012 07:58:50 +0000</pubDate>
		<dc:creator>shen2</dc:creator>
				<category><![CDATA[服务器端]]></category>
		<category><![CDATA[$_POST]]></category>
		<category><![CDATA[Content-Type]]></category>
		<category><![CDATA[header]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://shen2.cn/?p=980</guid>
		<description><![CDATA[今天出现一个诡异的情况，$HTTP_RAW_POST_DATA是有值的，但是$_POST却是空的array()。 反复尝试后发现是因为header中缺少Content-Type，设置Content-Type : application/x-www-form-urlencoded; charset=UTF-8 之后，就搞定了。 非常诡异的问题，总之以后养成设置Content-Type的好习惯就对了。 分享到： 新浪微博 QQ空间 开心网 人人网]]></description>
			<content:encoded><![CDATA[<p>今天出现一个诡异的情况，$HTTP_RAW_POST_DATA是有值的，但是$_POST却是空的array()。</p>
<p>反复尝试后发现是因为header中缺少Content-Type，设置Content-Type : application/x-www-form-urlencoded; charset=UTF-8 之后，就搞定了。</p>
<p>非常诡异的问题，总之以后养成设置Content-Type的好习惯就对了。</p>
<div style=float:left><!-- JiaThis Button BEGIN -->
<div id="ckepop">
	<a href="http://www.jiathis.com/share/" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank">分享到：</a>
	<a title="分享到新浪微博" class="jiathis_button_tsina">新浪微博</a>
	<a title="分享到QQ空间" class="jiathis_button_qzone">QQ空间</a>
	<a title="分享到开心网" class="jiathis_button_kaixin001">开心网</a>
	<a title="分享到人人网" class="jiathis_button_renren">人人网</a>
</div>
<script type="text/javascript" src="http://v1.jiathis.com/code/jia.js" charset="utf-8"></script>
<!-- JiaThis Button END --></div>]]></content:encoded>
			<wfw:commentRss>http://shen2.cn/2012/03/http-header-content-type-post/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>关于APC的性能优化，请看下面这段话</title>
		<link>http://shen2.cn/2012/03/apc-performance-optimize/</link>
		<comments>http://shen2.cn/2012/03/apc-performance-optimize/#comments</comments>
		<pubDate>Sun, 25 Mar 2012 14:01:26 +0000</pubDate>
		<dc:creator>shen2</dc:creator>
				<category><![CDATA[未分类]]></category>

		<guid isPermaLink="false">http://shen2.cn/?p=968</guid>
		<description><![CDATA[If you want to make the best use out of autoload with an APC cache don&#8217;t use spl_autoload. It uses relative paths and thus will perform a stat even with apc.stat=0 (either that, or it doesn&#8217;t work at all). Instead make a custom function and use require/include with an absolute path (register it with spl_autoload_register). [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to make the best use out of autoload with an APC cache don&#8217;t use spl_autoload. It uses relative paths and thus will perform a stat even with apc.stat=0 (either that, or it doesn&#8217;t work at all).</p>
<p>Instead make a custom function and use require/include with an absolute path (register it with spl_autoload_register).</p>
<p>Do NOT use *_once functions or a relative path. This will fail harder than spl_autoload.</p>
<p>Also avoid using file_exists and is_file. This will also perform a stat.</p>
<p>Why are stats bad? Because they access the file system. PHP does have a stat cache that helps, but it defeats the purpose of apc.stat = 0.</p>
<p>It&#8217;s also good to keep in mind that it&#8217;s good to keep your custom autoload function simple. This is my Loader class:<br />
<code></code></p>
<pre>class Loader
{
    public static function registerAutoload()
    {
        return spl_autoload_register(array(__CLASS__, 'includeClass'));
    }

    public static function unregisterAutoload()
    {
        return spl_autoload_unregister(array(__CLASS__, 'includeClass'));
    }

    public static function includeClass($class)
    {
        require(PATH . '/' . strtr($class, '_\\', '//') . '.php');
    }
}</pre>
<p>Also want to point out that APC does an optimization with require/include (not *_once) with relative paths if require/include is done in the global scope (and isn&#8217;t conditional). So it would be a good idea to explicitly include files you know you&#8217;re going to use on every request (but don&#8217;t use *_once). You could, for example, add a &#8220;registerProfiledAutoload&#8221; to the above class and keep track of what you&#8217;re including to help you determine what you could explicitly include (during development, not production). The key is try not to make heavy use out of autoload.</p>
<p>If you must use relative paths and don&#8217;t care about having to lower-case your file-names then spl_autoload works great.</p>
<div style=float:left><!-- JiaThis Button BEGIN -->
<div id="ckepop">
	<a href="http://www.jiathis.com/share/" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank">分享到：</a>
	<a title="分享到新浪微博" class="jiathis_button_tsina">新浪微博</a>
	<a title="分享到QQ空间" class="jiathis_button_qzone">QQ空间</a>
	<a title="分享到开心网" class="jiathis_button_kaixin001">开心网</a>
	<a title="分享到人人网" class="jiathis_button_renren">人人网</a>
</div>
<script type="text/javascript" src="http://v1.jiathis.com/code/jia.js" charset="utf-8"></script>
<!-- JiaThis Button END --></div>]]></content:encoded>
			<wfw:commentRss>http://shen2.cn/2012/03/apc-performance-optimize/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>强制指定javascript的编码</title>
		<link>http://shen2.cn/2012/03/force-declare-javascript-charset/</link>
		<comments>http://shen2.cn/2012/03/force-declare-javascript-charset/#comments</comments>
		<pubDate>Thu, 15 Mar 2012 14:51:03 +0000</pubDate>
		<dc:creator>shen2</dc:creator>
				<category><![CDATA[服务器端]]></category>
		<category><![CDATA[charset]]></category>
		<category><![CDATA[gb2312]]></category>
		<category><![CDATA[gbk]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[utf-8]]></category>

		<guid isPermaLink="false">http://shen2.cn/?p=965</guid>
		<description><![CDATA[部分用gb2312编码的用户反应javascript装载之后出现乱码，还有各种奇怪的问题，明显都是把utf-8的javascript当成gb2312来解析导致的。 首先尝试了给&#60;script&#62;标签加上chareset=&#8221;utf-8&#8243;，解决了部分问题，但是仍然部分情况下是乱码。 接着尝试了类似css的 @charset &#8220;utf-8&#8243;，IE直接报错。 最后发现还是web server设置header最靠谱。nginx设置header方法是在server的配置中加入: charset utf-8; 分享到： 新浪微博 QQ空间 开心网 人人网]]></description>
			<content:encoded><![CDATA[<p>部分用gb2312编码的用户反应javascript装载之后出现乱码，还有各种奇怪的问题，明显都是把utf-8的javascript当成gb2312来解析导致的。</p>
<p>首先尝试了给&lt;script&gt;标签加上chareset=&#8221;utf-8&#8243;，解决了部分问题，但是仍然部分情况下是乱码。</p>
<p>接着尝试了类似css的 @charset &#8220;utf-8&#8243;，IE直接报错。</p>
<p>最后发现还是web server设置header最靠谱。nginx设置header方法是在server的配置中加入:<br />
<code><br />
charset utf-8;<br />
</code></p>
<div style=float:left><!-- JiaThis Button BEGIN -->
<div id="ckepop">
	<a href="http://www.jiathis.com/share/" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank">分享到：</a>
	<a title="分享到新浪微博" class="jiathis_button_tsina">新浪微博</a>
	<a title="分享到QQ空间" class="jiathis_button_qzone">QQ空间</a>
	<a title="分享到开心网" class="jiathis_button_kaixin001">开心网</a>
	<a title="分享到人人网" class="jiathis_button_renren">人人网</a>
</div>
<script type="text/javascript" src="http://v1.jiathis.com/code/jia.js" charset="utf-8"></script>
<!-- JiaThis Button END --></div>]]></content:encoded>
			<wfw:commentRss>http://shen2.cn/2012/03/force-declare-javascript-charset/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>最好还是设置一下date.timezone</title>
		<link>http://shen2.cn/2012/03/%e6%9c%80%e5%a5%bd%e8%bf%98%e6%98%af%e8%ae%be%e7%bd%ae%e4%b8%80%e4%b8%8bdate-timezone/</link>
		<comments>http://shen2.cn/2012/03/%e6%9c%80%e5%a5%bd%e8%bf%98%e6%98%af%e8%ae%be%e7%bd%ae%e4%b8%80%e4%b8%8bdate-timezone/#comments</comments>
		<pubDate>Sat, 10 Mar 2012 21:17:43 +0000</pubDate>
		<dc:creator>shen2</dc:creator>
				<category><![CDATA[未分类]]></category>

		<guid isPermaLink="false">http://shen2.cn/?p=963</guid>
		<description><![CDATA[php 5.4.0开始，针对那那些既没有设置date.timezone，也没有执行过date_default_timezone_set()函数的情况下执行date()函数，开始抛出warning。所以还是最好在php.ini或者fpm.conf中设置一下timezone吧 It is not safe to rely on the system&#8217;s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone &#8216;UTC&#8217; for now, but [...]]]></description>
			<content:encoded><![CDATA[<p>php 5.4.0开始，针对那那些既没有设置date.timezone，也没有执行过date_default_timezone_set()函数的情况下执行date()函数，开始抛出warning。所以还是最好在php.ini或者fpm.conf中设置一下timezone吧<br />
It is not safe to rely on the system&#8217;s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone &#8216;UTC&#8217; for now, but please set date.timezone to select your timezone.</p>
<div style=float:left><!-- JiaThis Button BEGIN -->
<div id="ckepop">
	<a href="http://www.jiathis.com/share/" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank">分享到：</a>
	<a title="分享到新浪微博" class="jiathis_button_tsina">新浪微博</a>
	<a title="分享到QQ空间" class="jiathis_button_qzone">QQ空间</a>
	<a title="分享到开心网" class="jiathis_button_kaixin001">开心网</a>
	<a title="分享到人人网" class="jiathis_button_renren">人人网</a>
</div>
<script type="text/javascript" src="http://v1.jiathis.com/code/jia.js" charset="utf-8"></script>
<!-- JiaThis Button END --></div>]]></content:encoded>
			<wfw:commentRss>http://shen2.cn/2012/03/%e6%9c%80%e5%a5%bd%e8%bf%98%e6%98%af%e8%ae%be%e7%bd%ae%e4%b8%80%e4%b8%8bdate-timezone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>curl的header参数</title>
		<link>http://shen2.cn/2012/03/curl%e7%9a%84header%e5%8f%82%e6%95%b0/</link>
		<comments>http://shen2.cn/2012/03/curl%e7%9a%84header%e5%8f%82%e6%95%b0/#comments</comments>
		<pubDate>Thu, 08 Mar 2012 14:37:40 +0000</pubDate>
		<dc:creator>shen2</dc:creator>
				<category><![CDATA[服务器端]]></category>

		<guid isPermaLink="false">http://shen2.cn/?p=949</guid>
		<description><![CDATA[今天解决一个问题，服务器去连一些主机，总是得到错误的结果，连另一些却完全没问题。 查了半天，发现是curl有一个header参数，Expect:，如果不设置，则会输出一个Expect:100-continue（curl默认行为），一些webserver不认识这个，于是就出错了。 解决办法是设置&#8217;Expect:&#8217; 鸟哥曾经在博客中介绍过这个： http://www.laruence.com/2011/01/20/1840.html 分享到： 新浪微博 QQ空间 开心网 人人网]]></description>
			<content:encoded><![CDATA[<p>今天解决一个问题，服务器去连一些主机，总是得到错误的结果，连另一些却完全没问题。</p>
<p>查了半天，发现是curl有一个header参数，Expect:，如果不设置，则会输出一个Expect:100-continue（curl默认行为），一些webserver不认识这个，于是就出错了。</p>
<p>解决办法是设置&#8217;Expect:&#8217;</p>
<p>鸟哥曾经在博客中介绍过这个：<br />
<a href="http://www.laruence.com/2011/01/20/1840.html" target="_blank">http://www.laruence.com/2011/01/20/1840.html</a></p>
<div style=float:left><!-- JiaThis Button BEGIN -->
<div id="ckepop">
	<a href="http://www.jiathis.com/share/" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank">分享到：</a>
	<a title="分享到新浪微博" class="jiathis_button_tsina">新浪微博</a>
	<a title="分享到QQ空间" class="jiathis_button_qzone">QQ空间</a>
	<a title="分享到开心网" class="jiathis_button_kaixin001">开心网</a>
	<a title="分享到人人网" class="jiathis_button_renren">人人网</a>
</div>
<script type="text/javascript" src="http://v1.jiathis.com/code/jia.js" charset="utf-8"></script>
<!-- JiaThis Button END --></div>]]></content:encoded>
			<wfw:commentRss>http://shen2.cn/2012/03/curl%e7%9a%84header%e5%8f%82%e6%95%b0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>用php渲染javascript</title>
		<link>http://shen2.cn/2012/03/use-php-to-render-javascript/</link>
		<comments>http://shen2.cn/2012/03/use-php-to-render-javascript/#comments</comments>
		<pubDate>Thu, 08 Mar 2012 02:33:07 +0000</pubDate>
		<dc:creator>shen2</dc:creator>
				<category><![CDATA[服务器端]]></category>
		<category><![CDATA[access denied]]></category>
		<category><![CDATA[fpm]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[limit_extensions]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://shen2.cn/?p=955</guid>
		<description><![CDATA[在webapp时代，代码开发的重心转移到了javascript端，几乎不可避免的，我们会需要在javascript代码中插入一些和数据/环境有关的动态代码。 用php渲染javascript是最简单有效的方法。 不过在php5-fpm 5.3.10版本中，直接用php渲染.js文件，会出现一个Access denied.错误。 网上搜了好几回，才发现新版本php-fpm中增加了一个蛋疼的选项：security.limit_extensions，默认值是.php 也就是说如果.js文件送到php-fpm处理会以安全为由拒绝，把.js加入security.limit_extensions就可以了。 分享到： 新浪微博 QQ空间 开心网 人人网]]></description>
			<content:encoded><![CDATA[<p>在webapp时代，代码开发的重心转移到了javascript端，几乎不可避免的，我们会需要在javascript代码中插入一些和数据/环境有关的动态代码。</p>
<p>用php渲染javascript是最简单有效的方法。</p>
<p>不过在php5-fpm 5.3.10版本中，直接用php渲染.js文件，会出现一个Access denied.错误。</p>
<p>网上搜了好几回，才发现新版本php-fpm中增加了一个蛋疼的选项：security.limit_extensions，默认值是.php</p>
<p>也就是说如果.js文件送到php-fpm处理会以安全为由拒绝，把.js加入security.limit_extensions就可以了。</p>
<div style=float:left><!-- JiaThis Button BEGIN -->
<div id="ckepop">
	<a href="http://www.jiathis.com/share/" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank">分享到：</a>
	<a title="分享到新浪微博" class="jiathis_button_tsina">新浪微博</a>
	<a title="分享到QQ空间" class="jiathis_button_qzone">QQ空间</a>
	<a title="分享到开心网" class="jiathis_button_kaixin001">开心网</a>
	<a title="分享到人人网" class="jiathis_button_renren">人人网</a>
</div>
<script type="text/javascript" src="http://v1.jiathis.com/code/jia.js" charset="utf-8"></script>
<!-- JiaThis Button END --></div>]]></content:encoded>
			<wfw:commentRss>http://shen2.cn/2012/03/use-php-to-render-javascript/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>true or false?</title>
		<link>http://shen2.cn/2012/02/true-or-false/</link>
		<comments>http://shen2.cn/2012/02/true-or-false/#comments</comments>
		<pubDate>Sat, 25 Feb 2012 16:42:29 +0000</pubDate>
		<dc:creator>shen2</dc:creator>
				<category><![CDATA[未分类]]></category>

		<guid isPermaLink="false">http://shen2.cn/?p=946</guid>
		<description><![CDATA[最近在看同伴们的代码。发现if else的部分总是会出现一些意外的情况。 对于js/php这样的弱类型语言来说，代码书写虽然非常灵活，但实际上却充满陷阱，边缘条件下都非常容易出错。 比如整数0和字符串&#8217;0&#8242;: 对于javascript来说，0是false，而&#8217;0&#8242;是true。但是对于php来说，0是false，&#8217;0&#8242;也是false。 再蛋疼一点，字符串&#8217;00&#8242;，在php中，竟然变成true。 分享到： 新浪微博 QQ空间 开心网 人人网]]></description>
			<content:encoded><![CDATA[<p>最近在看同伴们的代码。发现if else的部分总是会出现一些意外的情况。<br />
对于js/php这样的弱类型语言来说，代码书写虽然非常灵活，但实际上却充满陷阱，边缘条件下都非常容易出错。</p>
<p>比如整数0和字符串&#8217;0&#8242;:<br />
对于javascript来说，0是false，而&#8217;0&#8242;是true。但是对于php来说，0是false，&#8217;0&#8242;也是false。</p>
<p>再蛋疼一点，字符串&#8217;00&#8242;，在php中，竟然变成true。</p>
<div style=float:left><!-- JiaThis Button BEGIN -->
<div id="ckepop">
	<a href="http://www.jiathis.com/share/" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank">分享到：</a>
	<a title="分享到新浪微博" class="jiathis_button_tsina">新浪微博</a>
	<a title="分享到QQ空间" class="jiathis_button_qzone">QQ空间</a>
	<a title="分享到开心网" class="jiathis_button_kaixin001">开心网</a>
	<a title="分享到人人网" class="jiathis_button_renren">人人网</a>
</div>
<script type="text/javascript" src="http://v1.jiathis.com/code/jia.js" charset="utf-8"></script>
<!-- JiaThis Button END --></div>]]></content:encoded>
			<wfw:commentRss>http://shen2.cn/2012/02/true-or-false/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>购买了Linode 512主机，架了一个VPN翻墙</title>
		<link>http://shen2.cn/2012/02/linode-512-vps-vpn-pptpd/</link>
		<comments>http://shen2.cn/2012/02/linode-512-vps-vpn-pptpd/#comments</comments>
		<pubDate>Sat, 18 Feb 2012 07:54:17 +0000</pubDate>
		<dc:creator>shen2</dc:creator>
				<category><![CDATA[服务器端]]></category>
		<category><![CDATA[Linode]]></category>
		<category><![CDATA[pptpd]]></category>
		<category><![CDATA[sysctl]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[VPN]]></category>
		<category><![CDATA[VPS]]></category>
		<category><![CDATA[翻墙代理]]></category>

		<guid isPermaLink="false">http://shen2.cn/?p=944</guid>
		<description><![CDATA[两年前买的HostMonster主机快要到期了，准备物色新主机。由于需求越来越复杂，我需要一个可以完全自己配置的环境，于是基于Xen的VPS主机Linode成了最佳选择，再加上它最近开通了东京数据中心，从国内ping只有120ms，绝对是翻墙越货最佳之选。 花了一个小时就搞定了信用卡支付，ubuntu系统的安装，nginx/php5/mysql/phpmyadmin安装，在国内的独立服务器上已经干过无数次了。基本上都快成为本能了。 值得一提的是在东京机房使用ubuntu的apt-get，需要修改一下源。日本最快的源是jp.archive.ubuntu.com，批量将us.archive.ubuntu.com替换成jp.archive.ubuntu.com就可以了。 接下来，就是配置VPN了，这才是VPS主机最大的价值。 先安装pptpd： apt-get install pptpd 配置pptpd: 修改/etc/pptpd.conf配置文件，将以下两行的注释去掉 localip 192.168.0.1 remoteip 192.168.0.201-245 修改/etc/ppp/options配置文件，根据服务器所在的网络设置DNS服务器，我的Linode东京节点的DNS服务器设置是： ms-dns 106.187.34.20 ms-dns 106.187.35.20 ms-dns 106.187.36.20 我后来发现似乎不设置DNS也可以，系统会直接使用服务器/etc/resolve.conf中的设置。 修改/etc/ppp/chap-secrets文件，设置密码 username pptpd password * 至此vpn已经可以直接拨通了，注意，在ubuntu上连接VPN要把Use Point-to-Point encryption (MPPE)的选项勾上。 修改/etc/sysctl.conf net.ipv4.ip_forward=1 修改/etc/rc.local，加入： iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE 然后重启，就大功告成啦！twitter/facebook的打开速度嗷嗷快。 分享到： 新浪微博 QQ空间 开心网 人人网]]></description>
			<content:encoded><![CDATA[<p>两年前买的HostMonster主机快要到期了，准备物色新主机。由于需求越来越复杂，我需要一个可以完全自己配置的环境，于是基于Xen的VPS主机Linode成了最佳选择，再加上它最近开通了东京数据中心，从国内ping只有120ms，绝对是翻墙越货最佳之选。</p>
<p>花了一个小时就搞定了信用卡支付，ubuntu系统的安装，nginx/php5/mysql/phpmyadmin安装，在国内的独立服务器上已经干过无数次了。基本上都快成为本能了。</p>
<p>值得一提的是在东京机房使用ubuntu的apt-get，需要修改一下源。日本最快的源是jp.archive.ubuntu.com，批量将us.archive.ubuntu.com替换成jp.archive.ubuntu.com就可以了。</p>
<p>接下来，就是配置VPN了，这才是VPS主机最大的价值。</p>
<ol>
<li>先安装pptpd：<br />
<code>apt-get install pptpd</code></li>
<li>配置pptpd:<br />
修改/etc/pptpd.conf配置文件，将以下两行的注释去掉<br />
<code>localip 192.168.0.1<br />
remoteip 192.168.0.201-245<br />
</code>
</li>
<li>修改/etc/ppp/options配置文件，根据服务器所在的网络设置DNS服务器，我的Linode东京节点的DNS服务器设置是：<br />
<code><br />
ms-dns 106.187.34.20<br />
ms-dns 106.187.35.20<br />
ms-dns 106.187.36.20</code><br />
我后来发现似乎不设置DNS也可以，系统会直接使用服务器/etc/resolve.conf中的设置。
</li>
<li>修改/etc/ppp/chap-secrets文件，设置密码<br />
<code>username pptpd password *</code><br />
至此vpn已经可以直接拨通了，注意，在ubuntu上连接VPN要把Use Point-to-Point encryption (MPPE)的选项勾上。</li>
<li>修改/etc/sysctl.conf<br />
<code>net.ipv4.ip_forward=1</code></li>
<li>修改/etc/rc.local，加入：<br />
<code>iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE</code><br />
然后重启，就大功告成啦！twitter/facebook的打开速度嗷嗷快。
</li>
</ol>
<div style=float:left><!-- JiaThis Button BEGIN -->
<div id="ckepop">
	<a href="http://www.jiathis.com/share/" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank">分享到：</a>
	<a title="分享到新浪微博" class="jiathis_button_tsina">新浪微博</a>
	<a title="分享到QQ空间" class="jiathis_button_qzone">QQ空间</a>
	<a title="分享到开心网" class="jiathis_button_kaixin001">开心网</a>
	<a title="分享到人人网" class="jiathis_button_renren">人人网</a>
</div>
<script type="text/javascript" src="http://v1.jiathis.com/code/jia.js" charset="utf-8"></script>
<!-- JiaThis Button END --></div>]]></content:encoded>
			<wfw:commentRss>http://shen2.cn/2012/02/linode-512-vps-vpn-pptpd/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>在header信息中隐藏php信息</title>
		<link>http://shen2.cn/2012/02/hide-version-infomation-in-header/</link>
		<comments>http://shen2.cn/2012/02/hide-version-infomation-in-header/#comments</comments>
		<pubDate>Fri, 17 Feb 2012 13:25:59 +0000</pubDate>
		<dc:creator>shen2</dc:creator>
				<category><![CDATA[服务器端]]></category>
		<category><![CDATA[header]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[X-Powered-By]]></category>
		<category><![CDATA[安全]]></category>
		<category><![CDATA[版本号]]></category>

		<guid isPermaLink="false">http://shen2.cn/?p=940</guid>
		<description><![CDATA[在php渲染的网页header信息中，会包含php的版本号信息，比如: X-Powered-by: php/5.3.3，这有些不安全，有些黑客可能采用扫描的方式，批量寻找低版本的php服务器，利用php漏洞(比如最近流行的hash冲突)来攻击服务器。 php.ini中有一个选项可以控制是否暴露这个信息，那就是： expose_php = On 默认值是On，改成Off之后，就不会显示php版本信息啦。 或者在php-fpm的pool配置文件中设置： php_admin_flag[expose_php] = off 分享到： 新浪微博 QQ空间 开心网 人人网]]></description>
			<content:encoded><![CDATA[<p>在php渲染的网页header信息中，会包含php的版本号信息，比如: X-Powered-by: php/5.3.3，这有些不安全，有些黑客可能采用扫描的方式，批量寻找低版本的php服务器，利用php漏洞(比如最近流行的hash冲突)来攻击服务器。</p>
<p>php.ini中有一个选项可以控制是否暴露这个信息，那就是：<br />
<code>expose_php = On</code><br />
默认值是On，改成Off之后，就不会显示php版本信息啦。</p>
<p>或者在php-fpm的pool配置文件中设置：<br />
<code><br />
php_admin_flag[expose_php] = off<br />
</code></p>
<div style=float:left><!-- JiaThis Button BEGIN -->
<div id="ckepop">
	<a href="http://www.jiathis.com/share/" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank">分享到：</a>
	<a title="分享到新浪微博" class="jiathis_button_tsina">新浪微博</a>
	<a title="分享到QQ空间" class="jiathis_button_qzone">QQ空间</a>
	<a title="分享到开心网" class="jiathis_button_kaixin001">开心网</a>
	<a title="分享到人人网" class="jiathis_button_renren">人人网</a>
</div>
<script type="text/javascript" src="http://v1.jiathis.com/code/jia.js" charset="utf-8"></script>
<!-- JiaThis Button END --></div>]]></content:encoded>
			<wfw:commentRss>http://shen2.cn/2012/02/hide-version-infomation-in-header/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>重负荷nginx的几个关键配置参数</title>
		<link>http://shen2.cn/2012/02/nginx-configuration/</link>
		<comments>http://shen2.cn/2012/02/nginx-configuration/#comments</comments>
		<pubDate>Wed, 15 Feb 2012 09:27:44 +0000</pubDate>
		<dc:creator>shen2</dc:creator>
				<category><![CDATA[服务器端]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[nginx.conf]]></category>
		<category><![CDATA[配置]]></category>

		<guid isPermaLink="false">http://shen2.cn/?p=937</guid>
		<description><![CDATA[不知不觉网站PV就爆发了。nginx压力越来越大，一些默认参数就显得不够用了。 我们的主服务器硬件配置非常健壮(双路至强5620 + 48GB内存 + SSD)，理论上可以承受每天过500万的PV，当然，前提是优化得够好。 简单罗列一下优化过的几个参数： ulimit -n 65535这个参数位于/etc/default/nginx 中，或者/etc/init.d/nginx 文件中直接设置。 默认是1024，意思是最多打开的文件个数。1024怎么够，至少开到8192，网上很多文章都直接开到了65535。 worker_processes 8; worker数量，位于nginx.conf头部，一般来说有几个cpu核心开几个，不算超线程。 worker_rlimit_nofile  65535; 位于nginx.conf头部，也是文件数量限制，直接开大吧。 worker_connections 4096; 位于nginx.conf中，默认是1024，也不够。 另外，建议编译nginx的时候顺带编译status模块，以便监视性能。 location /status/ { stub_status on; } 小小炫耀一下服务器的status参数，想当年刚用nginx的时候，Writing参数不是0就是1，现在已经这么大了: Active connections: 2140 server accepts handled requests 14727928 14727602 24524267 Reading: 92 Writing: 28 Waiting: 2020 分享到： 新浪微博 QQ空间 开心网 人人网]]></description>
			<content:encoded><![CDATA[<p>不知不觉网站PV就爆发了。nginx压力越来越大，一些默认参数就显得不够用了。</p>
<p>我们的主服务器硬件配置非常健壮(双路至强5620 + 48GB内存 + SSD)，理论上可以承受每天过500万的PV，当然，前提是优化得够好。</p>
<p>简单罗列一下优化过的几个参数：</p>
<ol>
<li>ulimit -n 65535这个参数位于/etc/default/nginx 中，或者/etc/init.d/nginx 文件中直接设置。
<p>默认是1024，意思是最多打开的文件个数。1024怎么够，至少开到8192，网上很多文章都直接开到了65535。</li>
<li>worker_processes 8;<br />
worker数量，位于nginx.conf头部，一般来说有几个cpu核心开几个，不算超线程。</li>
<li>worker_rlimit_nofile  65535;<br />
位于nginx.conf头部，也是文件数量限制，直接开大吧。</li>
<li>worker_connections 4096;<br />
位于nginx.conf中，默认是1024，也不够。</li>
<li>另外，建议编译nginx的时候顺带编译status模块，以便监视性能。<br />
<code><br />
location /status/ {<br />
stub_status on;<br />
}<br />
</code></li>
</ol>
<p>小小炫耀一下服务器的status参数，想当年刚用nginx的时候，Writing参数不是0就是1，现在已经这么大了:</p>
<pre>Active connections: 2140
server accepts handled requests
 14727928 14727602 24524267
Reading: 92 Writing: 28 Waiting: 2020</pre>
<div style=float:left><!-- JiaThis Button BEGIN -->
<div id="ckepop">
	<a href="http://www.jiathis.com/share/" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank">分享到：</a>
	<a title="分享到新浪微博" class="jiathis_button_tsina">新浪微博</a>
	<a title="分享到QQ空间" class="jiathis_button_qzone">QQ空间</a>
	<a title="分享到开心网" class="jiathis_button_kaixin001">开心网</a>
	<a title="分享到人人网" class="jiathis_button_renren">人人网</a>
</div>
<script type="text/javascript" src="http://v1.jiathis.com/code/jia.js" charset="utf-8"></script>
<!-- JiaThis Button END --></div>]]></content:encoded>
			<wfw:commentRss>http://shen2.cn/2012/02/nginx-configuration/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

