<?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; vps</title>
	<atom:link href="http://bluehua.org/tag/vps/feed" rel="self" type="application/rss+xml" />
	<link>http://bluehua.org</link>
	<description>分享所学,backup一切~</description>
	<lastBuildDate>Wed, 23 Nov 2011 08:43:10 +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>简单的blog增量备份shell</title>
		<link>http://bluehua.org/2010/04/11/1100.html</link>
		<comments>http://bluehua.org/2010/04/11/1100.html#comments</comments>
		<pubDate>Sun, 11 Apr 2010 08:57:43 +0000</pubDate>
		<dc:creator>冥王星2011</dc:creator>
				<category><![CDATA[other]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[vps]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=1100</guid>
		<description><![CDATA[blog内容越来越多,完全备份已经玩不起了,终于用到了tar的增量备份功能~~ 这个简单的备份脚本需要安装mutt(用来发mail) : sudo apt-get install mutt 或者 yum install mutt #!/bin/sh #blog根目录 dir=&#34;/home/hualu/blog&#34; #本地备份目录 backdir=&#34;/var/backup/bluehua/&#34; #将备份发送到email mail=&#34;emptyhua+backup@gmail.com&#34; dbname=&#34;数据库名&#34; dbuser=&#34;mysql用户名&#34; dbpass=&#34;mysql密码&#34; file=&#34;${backdir}backup-`date \&#34;+%Y-%m-%d\&#34;`.tar.gz&#34; sql=&#34;./sql_backup_${RANDOM}.sql&#34; cd &#34;$dir&#34; mysqldump --user=${dbuser} --password=${dbpass} ${dbname} &#62; ${sql} #增量打包,第一次运行会打包全部,以后都只会打包修改和新增的文件 #由于启用了cache插件,所以将cache目录排除在外 tar -g ${backdir}cookie -zcvf ${file} --exclude=./wp-content/cache* ./ rm -f ${sql} #将备份发送到mail echo &#34;blog备份&#34; &#124; mutt -s &#34;blog备份 `date \&#34;+%Y-%m-%d\&#34;`&#34; -a ${file} [...]]]></description>
			<content:encoded><![CDATA[<p>blog内容越来越多,完全备份已经玩不起了,终于用到了tar的增量备份功能~~<br />
这个简单的备份脚本需要安装mutt(用来发mail) : sudo apt-get install mutt 或者 yum install mutt</p>

<div class="wp_syntax"><div class="code overflow"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #666666; font-style: italic;">#blog根目录</span>
<span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">dir</span></span>=<span style="color: #ff0000;">&quot;/home/hualu/blog&quot;</span>
<span style="color: #666666; font-style: italic;">#本地备份目录</span>
<span style="color: #007800;">backdir</span>=<span style="color: #ff0000;">&quot;/var/backup/bluehua/&quot;</span>
<span style="color: #666666; font-style: italic;">#将备份发送到email</span>
<span style="color: #007800;">mail</span>=<span style="color: #ff0000;">&quot;emptyhua+backup@gmail.com&quot;</span>
<span style="color: #007800;">dbname</span>=<span style="color: #ff0000;">&quot;数据库名&quot;</span>
<span style="color: #007800;">dbuser</span>=<span style="color: #ff0000;">&quot;mysql用户名&quot;</span>
<span style="color: #007800;">dbpass</span>=<span style="color: #ff0000;">&quot;mysql密码&quot;</span>
<span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">file</span></span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${backdir}</span>backup-<span style="color: #780078;">`date \&quot;+%Y-%m-%d\&quot;`</span>.tar.gz&quot;</span>
<span style="color: #007800;">sql</span>=<span style="color: #ff0000;">&quot;./sql_backup_<span style="color: #007800;">${RANDOM}</span>.sql&quot;</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$dir</span>&quot;</span> 
mysqldump <span style="color: #660033;">--user</span>=<span style="color: #800000;">${dbuser}</span> <span style="color: #660033;">--password</span>=<span style="color: #800000;">${dbpass}</span> <span style="color: #800000;">${dbname}</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #800000;">${sql}</span> 
<span style="color: #666666; font-style: italic;">#增量打包,第一次运行会打包全部,以后都只会打包修改和新增的文件</span>
<span style="color: #666666; font-style: italic;">#由于启用了cache插件,所以将cache目录排除在外</span>
<span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-g</span> <span style="color: #800000;">${backdir}</span>cookie <span style="color: #660033;">-zcvf</span> <span style="color: #800000;">${file}</span> <span style="color: #660033;">--exclude</span>=.<span style="color: #000000; font-weight: bold;">/</span>wp-content<span style="color: #000000; font-weight: bold;">/</span>cache<span style="color: #000000; font-weight: bold;">*</span> .<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #800000;">${sql}</span> 
<span style="color: #666666; font-style: italic;">#将备份发送到mail</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;blog备份&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> mutt <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;blog备份 <span style="color: #780078;">`date \&quot;+%Y-%m-%d\&quot;`</span>&quot;</span> <span style="color: #660033;">-a</span> <span style="color: #800000;">${file}</span> <span style="color: #800000;">${mail}</span></pre></div></div>

<p><a href="http://bluehua.org/wp-content/uploads/2010/04/screenshot_061.png"><img src="http://bluehua.org/wp-content/uploads/2010/04/screenshot_061.png" alt="" title="screenshot_061" width="299" height="154" class="alignnone size-full wp-image-1109" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2010/04/11/1100.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>nginx反向代理kloxo</title>
		<link>http://bluehua.org/2010/01/14/810.html</link>
		<comments>http://bluehua.org/2010/01/14/810.html#comments</comments>
		<pubDate>Wed, 13 Jan 2010 16:53:59 +0000</pubDate>
		<dc:creator>冥王星2011</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[kloxo]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[vps]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=810</guid>
		<description><![CDATA[偶的vps配置真是几经波折。。 最开始 : centos + nginx + fastcgi + php，一个人用，任何修改都是直接ssh到server，一水的root 后来，搬家了,两个人用，加一个菜鸟的明星同学，考虑到傻瓜性，保留了默认安装的控制面板:centos + kloxo。kloxo可以选lighttpd, apache。由于一开始不知道能切apache，就用了lighttpd + fastcgi + php,结果发现每个人开三个fastcgi，128内存基本上就快光了，还有一点不爽的就是wp-super-cache的重写，如果用apache根本不用操心。。 备注:恩，由于kloxo的安全性考虑，每个用户的fastcgi都是单开的，不能共用 现如今，同样的vps配置，5个人共用，不得不再换个思路。首先fastcgi肯定不靠普了，每个人开2个，基本上就靠swap活着了，所以一定要用apache，apache里php以模块运行，多用户可以共用，所以apache进程只需开到2-3个，使用8080端口，然后前端再放nginx做代理，顺便处理静态文件。 恩，思路很简单，但是问题是，kloxo生成的虚拟主机配置文件全是80端口，想hack一下，发现源代码全被zend加密了。后来官网svn找到源码，端口竟然都是80写死在代码里的，修改之后覆盖到server上，发现不能添加域名了，说明版本太新，最后没办法，只能恶心一下了~ 每10秒钟检查一下配置文件，如果发现kloxo生成了80端口的配置文件，立刻替换成8080端口。脚本启动添加到/etc/rc.local里，开机运行。 #!/bin/sh while &#91; &#34;a&#34;=&#34;a&#34; &#93;;do find /home/httpd/ -type f -name &#34;kloxo.*&#34; &#124; xargs grep &#34;:80\\\\&#34; &#62; /tmp/kloxo_port if [ -n &#34;`cat /tmp/kloxo_port`&#34; ];then sh /root/kloxo_changeport.sh &#34;80&#34; &#34;8080&#34; sleep 2 echo &#34;restart httpd&#34; echo [...]]]></description>
			<content:encoded><![CDATA[<p>偶的vps配置真是几经波折。。</p>
<p>最开始 : centos + nginx + fastcgi + php，一个人用，任何修改都是直接ssh到server，一水的root</p>
<p>后来，搬家了,两个人用，加一个菜鸟的明星同学，考虑到傻瓜性，保留了默认安装的控制面板:centos + kloxo。kloxo可以选lighttpd, apache。由于一开始不知道能切apache，就用了lighttpd + fastcgi + php,结果发现每个人开三个fastcgi，128内存基本上就快光了，还有一点不爽的就是wp-super-cache的重写，如果用apache根本不用操心。。</p>
<p>备注:恩，由于kloxo的安全性考虑，每个用户的fastcgi都是单开的，不能共用</p>
<p>现如今，同样的vps配置，5个人共用，不得不再换个思路。首先fastcgi肯定不靠普了，每个人开2个，基本上就靠swap活着了，所以一定要用apache，apache里php以模块运行，多用户可以共用，所以apache进程只需开到2-3个，使用8080端口，然后前端再放nginx做代理，顺便处理静态文件。</p>
<p>恩，思路很简单，但是问题是，kloxo生成的虚拟主机配置文件全是80端口，想hack一下，发现源代码全被zend加密了。后来官网svn找到源码，端口竟然都是80写死在代码里的，修改之后覆盖到server上，发现不能添加域名了，说明版本太新，最后没办法，只能恶心一下了~</p>
<p>每10秒钟检查一下配置文件，如果发现kloxo生成了80端口的配置文件，立刻替换成8080端口。脚本启动添加到/etc/rc.local里，开机运行。</p>

<div class="wp_syntax"><div class="code overflow"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;a&quot;</span>=<span style="color: #ff0000;">&quot;a&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>;<span style="color: #000000; font-weight: bold;">do</span>
        <span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>httpd<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-type</span> f <span style="color: #660033;">-name</span> <span style="color: #ff0000;">&quot;kloxo.*&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">xargs</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;:80\\\<span style="color: #000099; font-weight: bold;">\&quot;</span> &gt; /tmp/kloxo_port 
        if [ -n &quot;</span><span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>kloxo_port<span style="color: #000000; font-weight: bold;">`</span><span style="color: #ff0000;">&quot; ];then
                sh /root/kloxo_changeport.sh &quot;</span><span style="color: #000000;">80</span><span style="color: #ff0000;">&quot; &quot;</span><span style="color: #000000;">8080</span><span style="color: #ff0000;">&quot;
                sleep 2
                echo &quot;</span>restart httpd<span style="color: #ff0000;">&quot;
                echo &quot;</span>restart httpd <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span><span style="color: #000000; font-weight: bold;">`</span><span style="color: #ff0000;">&quot; &gt;&gt; /var/log/httpd_restart.log
                /etc/init.d/httpd restart
        fi
        sleep 10
done</span></pre></div></div>

<p>用到的两个shell脚本下载 : <a href='http://bluehua.org/wp-content/uploads/2010/01/fuck-kloxo.zip'>fuck-kloxo</a></p>
<p>OK，解决完端口问题下面就是配置ngnix代理</p>
<pre>
#仅开了一个进程。。
worker_processes  1;
</pre>
<p>配置代理</p>

<div class="wp_syntax"><div class="code overflow"><pre class="text" style="font-family:monospace;">server {
        limit_conn   myzone  10;
        listen       80;
        server_name  _;
#静态文件不走代理，直接nginx处理
        location ~* .*\.(jpg|jpeg|png|gif|css|js|swf|mp3|avi|flv|xml|zip|rar)$ {
                add_header BlueNoProxy 1;
                expires 30d;
                root /home/httpd/$host/httpdocs;
        } 
#html文件由可能是固态链接，所以404之后依然走代理
        location ~* .*\.(html|htm)$ {
                add_header BlueNoProxy 1;
                root /home/httpd/$host/httpdocs;
                error_page 404 = @proxy;
        }
#这里ip不能用127.0.0.1,kloxo的配置文件里会根据外网ip划分虚拟主机
        location @proxy {
                proxy_pass        http://209.124.50.68:8080;
                proxy_set_header Host $host;
                proxy_set_header  x-real-IP  $remote_addr;
&nbsp;
        }
&nbsp;
        location / {
                proxy_pass        http://209.124.50.68:8080;
                proxy_set_header Host $host;
                proxy_set_header  x-real-IP  $remote_addr;
        }
&nbsp;
   }</pre></div></div>

<p>以上，偶的最新vps配置就over了~</p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2010/01/14/810.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>正式摆脱备案..</title>
		<link>http://bluehua.org/2009/12/12/714.html</link>
		<comments>http://bluehua.org/2009/12/12/714.html#comments</comments>
		<pubDate>Sat, 12 Dec 2009 15:54:27 +0000</pubDate>
		<dc:creator>冥王星2011</dc:creator>
				<category><![CDATA[other]]></category>
		<category><![CDATA[vps]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=714</guid>
		<description><![CDATA[偶的大小blog终于全家出国了.. 前两天忽然发现偶搭的difanghua.org访问不了了,但blog是好的,难道是权限问题? 可是好像没动过,于是又试了试我跟老婆的日记,也不行.再一看firebug的网络,header里服务器的标识竟然是apache&#8230;,我明明装的ngnix. 最后访问了下doc.bluehua.org, 竟然可以..这下我明白了,没有备案的域名全他文明用语给我屏蔽了.. 我已经出离愤怒了,尽管现在的空间还有半年才到期,但还是决定提前搬迁,少生点闷气.. 第一步 : 把我在国内注的域名转到godaddy google了下好像要这个转移的授权码还挺麻烦的,还要邮寄身份证户口本复印件啥的..,但出乎意料的是,我仅提交了两个工单,他们便把密码给我了,而且态度特好..,表扬一下这个非主流idc:九州未来 第二步:把所有网站搬到国外.. 自己租还是有点贵,于是顺便忽悠明星同学 跟我一块合组,找了几家都很贵的样子,最后找个一家叫a2hosting 的idc,速度不慢,价格适中,如下: $8.97 / Mon * 128 MB Dedicated RAM (256 MB Burstable) * 10 GB Disk Space * 100 GB Monthly Data Transfer * FREE Setup * No Contracts or Hidden Fees! * 30 Day Money Back Guarantee 同样单核cpu,虽然内存比我现在用的小了一半,但是运行速度却要快很多. 排出备案,一身轻松~~ 最后show一下哥新注的域名: http://hua.lu]]></description>
			<content:encoded><![CDATA[<p>偶的大小blog终于全家出国了..<img class="xemotion" src="http://bluehua.org/wp-content/plugins/x-emotions/emotions/msn/bofu3_22.gif" border="0" alt="" /></p>
<p>前两天忽然发现偶搭的<a href="http://difanghua.org">difanghua.org</a>访问不了了,但blog是好的,难道是权限问题? 可是好像没动过,于是又试了试我跟老婆的日记,也不行.再一看firebug的网络,header里服务器的标识竟然是apache&#8230;,我明明装的ngnix. 最后访问了下doc.bluehua.org, 竟然可以..这下我明白了,没有备案的域名全他文明用语给我屏蔽了..</p>
<p>我已经出离愤怒了,尽管现在的空间还有半年才到期,但还是决定提前搬迁,少生点闷气..</p>
<p>第一步 : 把我在国内注的域名转到godaddy</p>
<p>google了下好像要这个转移的授权码还挺麻烦的,还要邮寄身份证户口本复印件啥的..,但出乎意料的是,我仅提交了两个工单,他们便把密码给我了,而且态度特好..,表扬一下这个非主流idc:九州未来</p>
<p>第二步:把所有网站搬到国外..</p>
<p>自己租还是有点贵,于是顺便忽悠<a href="http://mingxingzhang.com">明星同学</a> 跟我一块合组,找了几家都很贵的样子,最后找个一家叫<a href="http://www.a2hosting.com/">a2hosting</a> 的idc,速度不慢,价格适中,如下:</p>
<pre>  <span>$8.97 / Mon</span>
    * 128 MB Dedicated RAM (256 MB Burstable)
    * 10 GB Disk Space
    * 100 GB Monthly Data Transfer
    * FREE Setup
    * No Contracts or Hidden Fees!
    * 30 Day Money Back Guarantee</pre>
<p>同样单核cpu,虽然内存比我现在用的小了一半,但是运行速度却要快很多.</p>
<p>排出备案,一身轻松~~</p>
<p>最后show一下哥新注的域名: <a href="http://hua.lu" target="_blank">http://hua.lu</a></p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2009/12/12/714.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>vps优化备忘</title>
		<link>http://bluehua.org/2009/05/27/305.html</link>
		<comments>http://bluehua.org/2009/05/27/305.html#comments</comments>
		<pubDate>Wed, 27 May 2009 12:13:40 +0000</pubDate>
		<dc:creator>冥王星2011</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[vps]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=305</guid>
		<description><![CDATA[网上安装配置文章很多，讲优化的却很少，备个忘 系统环境：centos5，128 RAM 安装的服务：nginx,fast_cgi,php5,mysql,vsftp 1.关闭没用的服务 #ntsysv &#8230;关的太多，最后剩下还在运行的服务 anacron atd auditd cpuspeed crond haldaemon iptalbes irqbalance readahead_early sshd syslog vmware-tools nginx vsftpd mysqld 2.关闭selinux #vi /etc/selinux/config SELINUX=disabled 3.mysql禁用innodb #vi /etc/my.cnf 在[mysqld]字段添加 skip-innodb 4.fast_cgi仅开了2个进程（哦，pv是什么我还不知道） 优化结果： # free -m total used free shared buffers cached Mem: 122 119 3 0 11 67 -/+ buffers/cache: 40 82 Swap: 509 [...]]]></description>
			<content:encoded><![CDATA[<p>网上安装配置文章很多，讲优化的却很少，备个忘<br />
系统环境：centos5，128 RAM<br />
安装的服务：nginx,fast_cgi,php5,mysql,vsftp</p>
<p>
1.关闭没用的服务</p>

<div class="wp_syntax"><div class="code overflow"><pre class="text" style="font-family:monospace;">#ntsysv</pre></div></div>

<p>&#8230;关的太多，最后剩下还在运行的服务<br />
anacron atd auditd cpuspeed crond haldaemon iptalbes irqbalance readahead_early sshd  syslog vmware-tools nginx vsftpd mysqld
</p>
<p>
2.关闭selinux</p>

<div class="wp_syntax"><div class="code overflow"><pre class="text" style="font-family:monospace;">#vi /etc/selinux/config
SELINUX=disabled</pre></div></div>

</p>
<p>
3.mysql禁用innodb</p>

<div class="wp_syntax"><div class="code overflow"><pre class="text" style="font-family:monospace;">#vi /etc/my.cnf
在[mysqld]字段添加
skip-innodb</pre></div></div>

</p>
<p>
4.fast_cgi仅开了2个进程（哦，pv是什么我还不知道）
</p>
<p>优化结果：</p>

<div class="wp_syntax"><div class="code overflow"><pre class="text" style="font-family:monospace;"># free -m
total       used       free     shared    buffers     cached
Mem:           122        119          3          0         11         67
-/+ buffers/cache:         40         82
Swap:          509          0        509</pre></div></div>

<p>效果还可以<img class="xemotion" src="http://bluehua.org/wp-content/plugins/x-emotions/emotions/maomao/18.gif" border="0" alt="" /></p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2009/05/27/305.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.485 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-02-05 03:13:38 -->

