<?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>Best Larro!</title>
	<atom:link href="http://www.larro.cn/feed" rel="self" type="application/rss+xml" />
	<link>http://www.larro.cn</link>
	<description></description>
	<lastBuildDate>Fri, 02 Dec 2011 15:14:13 +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>Ubuntu Server 10.10安装配置Nginx+php-fpm+mysql</title>
		<link>http://www.larro.cn/archives/204</link>
		<comments>http://www.larro.cn/archives/204#comments</comments>
		<pubDate>Fri, 04 Nov 2011 11:39:40 +0000</pubDate>
		<dc:creator>larro</dc:creator>
				<category><![CDATA[CGI/FastCGI]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.larro.cn/?p=204</guid>
		<description><![CDATA[新安装的系统，软件包更新，首先找一个速度不错的Ubuntu源,这里网上搜了一个。 http://www.cnblogs.com/lei1016cn/archive/2010/10/21/1857761.html 更改源 vi /etc/apt/source.list 全部删除，加入下面的源。 ### Security Sourcelist deb http://security.ubuntu.com/ubuntu maverick-security main restricted deb-src http://security.ubuntu.com/ubuntu maverick-security main restricted deb http://security.ubuntu.com/ubuntu maverick-security universe deb-src http://security.ubuntu.com/ubuntu maverick-security universe deb http://security.ubuntu.com/ubuntu maverick-security multiverse deb-src http://security.ubuntu.com/ubuntu maverick-security multiverse ### 163.com Sourcelist deb http://mirrors.163.com/ubuntu/ maverick main universe restricted multiverse deb-src http://mirrors.163.com/ubuntu/ maverick main universe restricted multiverse deb http://mirrors.163.com/ubuntu/ maverick-security [...]]]></description>
		<wfw:commentRss>http://www.larro.cn/archives/204/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>工厂模式-工厂方法模式</title>
		<link>http://www.larro.cn/archives/185</link>
		<comments>http://www.larro.cn/archives/185#comments</comments>
		<pubDate>Mon, 19 Sep 2011 17:24:51 +0000</pubDate>
		<dc:creator>larro</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[设计模式]]></category>

		<guid isPermaLink="false">http://www.larro.cn/?p=185</guid>
		<description><![CDATA[工厂方法模式又称为工厂模式，也叫虚拟构造器（Virtual Construct）模式或者多态工厂模式（Polymorphic Factory），在工厂模式中，父类负责定义创建对象的接口，而真正实现创建对象的任务交给子类去实现。这样作的目的是将创建对象的工作延迟到子类中去完成，由子类决定生成哪个具体的对象。]]></description>
		<wfw:commentRss>http://www.larro.cn/archives/185/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>工厂模式-简单工厂模式</title>
		<link>http://www.larro.cn/archives/180</link>
		<comments>http://www.larro.cn/archives/180#comments</comments>
		<pubDate>Mon, 19 Sep 2011 16:39:33 +0000</pubDate>
		<dc:creator>larro</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[设计模式]]></category>

		<guid isPermaLink="false">http://www.larro.cn/?p=180</guid>
		<description><![CDATA[工厂模式就是负责将大量有共同接口的类实例，而不必事先知道要实例化哪一个类的模式。工厂模式一般分为三种：简单工厂模式、工厂方法模式、抽象工厂模式。从模式性质来说，工厂模式属于创建型模式。 简单工厂模式定义 通常负责创建实例工厂类接收一个条件(参数)，来决定实例化哪一个产品类。简单工厂模式又被称为静态工厂模式，但不属于23种GOF设计模式之一。简单工厂模式是由一个工厂对象决定创建出哪一种产品类的实例。简单工厂模式是工厂模式家族中最简单实用的模式，可以理解为是不同工厂模式的一个特殊实现。 &#60;?php // Simple Factory interface IAnimal { function Eat(); } class Dog implements IAnimal { public function Eat() { echo &#34;Dog Eat!&#34;; echo &#34;&#60;br/&#62;&#34;; } } class Cat implements IAnimal { public function Eat() { echo &#34;Cat Eat!&#34;; echo &#34;&#60;br/&#62;&#34;; } } class SimpleFactory { function CreateAnimal($animal_type) { switch ($animal_type) { case [...]]]></description>
		<wfw:commentRss>http://www.larro.cn/archives/180/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>计算机字、字节、字长之某腾讯面试题</title>
		<link>http://www.larro.cn/archives/170</link>
		<comments>http://www.larro.cn/archives/170#comments</comments>
		<pubDate>Thu, 25 Aug 2011 16:44:14 +0000</pubDate>
		<dc:creator>larro</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[算法分析]]></category>

		<guid isPermaLink="false">http://www.larro.cn/?p=170</guid>
		<description><![CDATA[常常我们说机器是32位或者64位的，这里面具体有些什么重要的信息呢？以及我们经常挂在嘴边的字节具体是什么概念？还有经常被忽略的”字“、”字长“。 字 首先，我们了解这么一个知识点，计算机在处理或者运算的时候，是把数据分成一个个固定长度数据串来处理的，这些一个个的细小数据串就是计算机的字。通常，一个字包含若干个字节（每个字节通常是8位，即8个二进制数）。而且，在存储器中，每个单元存储一个字，每个字又是可以通过寻址的，字的长度是用用位来表示的，即一个字能容纳多少位二进制数，即下面的字长。 字长 计算机中每个字的位数（二进制数的个数）就叫字长。根据计算机不同，字长分为固定字长、可变字长。固定字长，即字长度不论什么情况都是固定不变的；可变字长，则在一定范围内，其长度是可变的。 计算机的字长代表计算机的处理能力，是指它一次可处理的二进制数字的数目，即一次可处理计算的数据大小。计算机处理数据的速率，自然和它一次能加工的位数以及进行运算的快慢有关。如果一台计算机的字长是另一台计算机的两倍，即使两台计算机的速度相同，在相同的时间内，前者能做的工作是后者的两倍。我们常说的32位、64位机器就是说这些机器的字长度。字长大的机器CPU，假如相同处理速度的条件下，CPU的处理数据量与字长度成正比。因此，64位机器是要比32位更强！ 字节 在上面说到的字，每个字中包含若干个字节（通常一个字节占8位，8个二进制数），或者说字节是指一小组相邻的二进制数码，通常是8位（二进制数）作为一个字节。字节是构成信息的一个小单位，并作为一个整体来参加操作，比”字“小，是构成字的单位。 一个重要的信息：在计算机中，通常用多少字节来表示存储器的存储容量。例如，在C++的数据类型表示中，通常 char为1个字节，int为4个字节，double为8个字节。 有了上面的概念，我们来算算数据的存储。 1字节(byte) = 8 位(bit)   得到： 1kib = 2的10次方 bit = 1024 bit 即: 1kib=1024bit  或  1k字节(KiB,kilibyte) = 1024(字节) 同理， 1MiB=1024KiB 1M字节（MiB,Mebibyte）=1024K字节（2的20次方字节） 1GiB=1024MiB 1G字节（GiB,Gibibyte）=1024M字节（2的30次方字节） 1TiB=1024GiB 1T字节（TiB,Tebibyte）=1024G字节（2的40次方字节） 1PiB=1024TiB 1P字节（PiB,Pebibyte）=1024T字节（2的50次方字节） 1EiB=1024PiB 1 E字节（EiB,Exbibyte）=1024P字节（2的60次方字节） &#8230; 因为硬盘生产商是以GB（十进制，即10的3次方=1000，如1MB=1000KB）计算的，而电脑（操作系统）是以GiB(2进制，即2的 10次方，如 1MiB=1024KiB）计算的，国内用户一般不分MB与Mib以及Kb与kib，直接把1MB=1000 KB为1Mib=1024kib，所以好多160GB的硬盘实际容量按计算机 实际的1MiB=1024KiB算都不到160GiB，这也可以解释为什么新买的硬盘“缺斤短两”并没有它所标示的那么大。 最后，我们来看一道传说腾讯的面试题目： 问题 在一个文件中有 10G 个整数，乱序排列，要求找出中位数，内存限制为 2G,多少次计算能找出中位数？ 解答 [...]]]></description>
		<wfw:commentRss>http://www.larro.cn/archives/170/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>使用rsync备份网站数据(2)</title>
		<link>http://www.larro.cn/archives/159</link>
		<comments>http://www.larro.cn/archives/159#comments</comments>
		<pubDate>Thu, 04 Aug 2011 10:28:46 +0000</pubDate>
		<dc:creator>larro</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[rsync]]></category>

		<guid isPermaLink="false">http://www.larro.cn/?p=159</guid>
		<description><![CDATA[前面一篇文章比较详细的讲了关于rsync的配置，这里我们以具体的应用来讲讲如何使用rsync、crontab、shell来做网站数据的备份，还没配置好rsync服务的同学移步这里&#8211;使用rsync备份网站数据(1) 前面文章讲到rsync服务器可以配置多个同步备份项目，对于备份网站程序文件以及图片等静态文件来说我们可以直接配置rsync模块目录为网站根目录即可，比如备份整个WEB服务器根目录/var/www，可以这样配置成rsync的一个模块。 [larro] path = /var/www list=yes ignore errors auth users = root secrets file = /etc/rsyncd.secrets comment = This is the System file of Larro's Blog exclude = unrsync/ 对，这样就可以了。假定我们这台机器IP是192.168.1.1，然后我们在提供备份的机器上（192.168.1.2，同样安装了rsync服务）上只需要输入以下命令： rsync -avzP --password-file=/etc/rsync/rsync.passwd root@192.168.1.1::larro /data/backup/webhost 关于具体参数详细说明可以参考使用rsync备份网站数据(1)，或者官方文档http://www.samba.org/ftp/rsync/rsync.html 这样，就讲192.168.1.1机器上/var/www里所有文件备份到/data/backup/webhost里面去了，但是这样肯定不够，因为每次得手动去输入命令同步备份，于是我们借助Linux系统的crontab命令服务，让系统自己定时去备份，(crontab详细介绍). 接着编辑crontab，把上面备份命令直接写入crontab里面： crotab -e 在里面输入以下命令代码： 30 4 * * * /usr/bin/rsync -avzP --password-file=/etc/rsync/rsync.passwd root@192.168.1.1::larro /data/backup/webhost 上面命令表示，每天的4:30执行rsync命令，自动同步备份网站数据。 但是数据库MYSQL文件我们不好直接设置成MYSQL的数据库读写文件，例如/var/lib/mysql，数据库一直运行着，一直在读写着这些文件，如果我们直接使用rsync很容易出错，解决办法很多种，脚本里可以先停掉mysql服务，或者直接使用Mysqldump命令导出数据库文件然后打包到某个文件夹，我们把这个文件夹配置成一个rsync项目位置，然后再同步备份。 个人觉得使用mysqldump方式好点，也简单并且不必停掉mysql服务。 [...]]]></description>
		<wfw:commentRss>http://www.larro.cn/archives/159/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP设计模式之-单例模式</title>
		<link>http://www.larro.cn/archives/56</link>
		<comments>http://www.larro.cn/archives/56#comments</comments>
		<pubDate>Wed, 03 Aug 2011 11:50:53 +0000</pubDate>
		<dc:creator>larro</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[设计模式]]></category>

		<guid isPermaLink="false">http://www.larro.cn/?p=56</guid>
		<description><![CDATA[很多朋友学习接触设计模式的时候都是从单例模式、工厂模式等广泛应用的模式开始的，今天就来说说PHP的单例模式。

单例模式，也叫单子模式，使用这个模式时候，单例对象的类只能生成一个实例。恰是只能唯一生成一个类的实例对象在有的场合里面特别合适好用!]]></description>
		<wfw:commentRss>http://www.larro.cn/archives/56/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>使用rsync备份网站数据(1)</title>
		<link>http://www.larro.cn/archives/128</link>
		<comments>http://www.larro.cn/archives/128#comments</comments>
		<pubDate>Wed, 03 Aug 2011 07:47:03 +0000</pubDate>
		<dc:creator>larro</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[rsync]]></category>

		<guid isPermaLink="false">http://www.larro.cn/?p=128</guid>
		<description><![CDATA[前天干了件吐血的大事，是这样的，同事让我帮他清理下服务器上一些乱七八糟的用户，我cat下/etc/passwd文件，里面一堆的用户乱七八糟的用户文件，更为可耻的是有人还把用户加入sudoers里面去了（之前接触过该台服务器的人），我二话不说，一个个使劲的删，连同用户所属的文件也通通删了（使用命令usrdel -f -r xxx，以后删除东西的时候千万千万要注意-f参数，最好任何时候都别用），包括一些FTP账户，FTP用户直接使用的是本地用户，自然FTP是用来管理网站程序的，于是我也把它删了，悲剧发生了，这些FTP账户所属目录就是网站程序文件，一删除用户资料带着程序文件全删除了，后来网站不能访问了检查一遍机器其他问题后才发现问题，当时都没反应过来，之后那个悔，那个慌。还好有备份，不过这两天的图片没了得重新上传。 于是，在这件事情的基础上，就决定配置一个实时性比较强的数据备份，自然用rsync。至于rsync是什么东东，同学们自己Google或者百度去。 Ubuntu Server，Centos,Debian等安装rsync服务可以直接使用在线安装包。 sudo apt-get install rsync 或 yum install rsync 安装好了之后，我们接下来需要配置三个文件，分别是rsyncd.conf、rsyncd.motd、rsyncd.secrets,这三个文件分别是主配置文件、显示欢迎界面文件以及密码验证文件，并且rsyncd.conf默认是不存在的，得自己创建。 touch rsyncd.conf 接下来，在该配置文件里写入如下配置代码: # Distributed under the terms of the GNU General Public License v2 # Minimal configuration file for rsync daemon # See rsync(1) and rsyncd.conf(5) man pages for help # This line is required by the /etc/init.d/rsyncd [...]]]></description>
		<wfw:commentRss>http://www.larro.cn/archives/128/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>使用/proc虚拟文件系统查看优化WEB程序</title>
		<link>http://www.larro.cn/archives/95</link>
		<comments>http://www.larro.cn/archives/95#comments</comments>
		<pubDate>Wed, 27 Jul 2011 09:11:51 +0000</pubDate>
		<dc:creator>larro</dc:creator>
				<category><![CDATA[CGI/FastCGI]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nginx]]></category>

		<guid isPermaLink="false">http://www.larro.cn/?p=95</guid>
		<description><![CDATA[在服务器上，我们一般使用top命令工具来监视服务器进程和Linux整体性能。 top 将会看到如下结果界面： 会列出了进程PID,USER(所属用户),PR,%CPU,%MEM,COMMAND(命令或者服务)等参数的列表，这个显示列表是动态跟踪服务器的。 问题来了，在上面的监控中，主要查看$CPU,%MEM，COMMAND这几个参数值，上面可以看到排在前面的两个进程都肚子占用了一枚CPU的%100。另外也可以根据这个列表看出WEB服务器有多少个CPU，数数php5-cgi的行数就是了。 看到两个php-cgi进程貌似是因为程序存在问题死循环什么的了把当时处理这个脚本的CPU给占满了，在这里，虽然我们大概知道是程序某个地方存在严重的问题，但是我们不能具体定位出来到底是系统的哪段文件出问题了。 于是，/proc来帮我们了，我们找到哪个进程在耗CPU， 对，PID为24207和24219这两家伙，咱们来用/proc虚拟文件系统来定位吧。 ls -l /proc/24219 # 后面的数字为上面的PID 注意上图中蓝色的路径，对，这个路径就是此段程序执行的代码路径，定位到了吧，然后你就可以在这个路径下去找那原因了]]></description>
		<wfw:commentRss>http://www.larro.cn/archives/95/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>服务器流量监控工具-bmon</title>
		<link>http://www.larro.cn/archives/87</link>
		<comments>http://www.larro.cn/archives/87#comments</comments>
		<pubDate>Tue, 26 Jul 2011 09:43:32 +0000</pubDate>
		<dc:creator>larro</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nginx]]></category>

		<guid isPermaLink="false">http://www.larro.cn/?p=87</guid>
		<description><![CDATA[介绍一款服务器流量监控工具，Bmon，在Linux社区也比较常用，它提供的数据比较详细。 Ubuntu下安装 sudo apt-get install bmon 然后就可以查看某一块网卡的带宽流量情况了，比如查看eth0的： bmon -p eth0 可以看到如下显示： 其中，RX表示流入，TX流出，RX rate是流入比率，TX Rate流出比率。更多bmon用法可以man bmon查看。 另外，更加喜人的是它能提供与Apache/Nginx等WEB服务器配合以Html方式动态显示流量监控结果，输入以下命令： bmon -I distribution:multicast -o null -O html:path=/var/www/dirname/ 这里注意下，上面的目录”/var/www/dirname/”最好不要用网站的根目录，因为执行下这个命令的话，它会生成一个index.html文件，而我们网站一般由一个index默认文档，一般index解析为:index.html index.htm index.php这三个文件。 所以，当它生成的index.html替换网站根目录的index.html文件的时候，访问网站时候默认就访问到bmon的统计页面了。 我们可以把他放在其他位置，然后加一个Http Auth来设定一定的权限来查看。 比如我们的网站根目录是：/var/www/website 我们把它生成的统计文件放在/var/www/website/bmon下，通过配置Nginx的Http auth_basic来控制访问权限。 在网站配置文件里加下面这么一段 location ~ ^/bmon/ { auth_basic Hello_Auth; auth_basic_user_file /data/auth/manage_auth;&#60;/pre&#62; } 上面的auth_basic Hello_auth;只是给这个验证加一个类似提示语的，可以任何；auth_basic_user_file 是用来存储http登录账户密码的，得用htpasswd工具来生成。具体如下： htpasswd -c /data/passwd username 提示输入密码，就会创建一个username用户，并在/data/目录下生成username的passwd文件。 最终，通过浏览器访问http://www.xxx.com/bmon/就能看到监控的网页形式数据了。 &#160; &#160; &#160;]]></description>
		<wfw:commentRss>http://www.larro.cn/archives/87/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu下安装配置Subversion，并建立多个版本库</title>
		<link>http://www.larro.cn/archives/39</link>
		<comments>http://www.larro.cn/archives/39#comments</comments>
		<pubDate>Fri, 22 Jul 2011 09:27:26 +0000</pubDate>
		<dc:creator>larro</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.larro.cn/?p=39</guid>
		<description><![CDATA[公司有好几个网站项目，随着同一个项目接手开发的同学越来越多，版本控制变成一个必须的工具。交给我来配置，在这里记录下来； SVN可以有好几种连接方式，我这里使用的是自带的SVN://协议访问。还有通过配置apache2来使用http://访问。或者文件协议file://. 首先安装Subversion,服务器环境为Ubuntu Server. sudo apt-get install subversion 安装成功后，就创建版本库了。 先创建一个存放版本库的文件夹，方便管理。 mkdir /var/svn 根据项目需要，创建几个不同的版本库。 cd /var/svn svnadmin create /var/svn/aaa 执行以上命令后，可以查看aaa这个文件夹里有些什么东西： cd aaa ls 会看到列出：conf  db  format  hooks  locks  README.txt 进入配置文件夹conf,输命令： cd conf ls 可以看到列出：authz  passwd  svnserve.conf几个文件，这里说明下： svnserve.conf:这个版本库的配置文件，包括如何验证SVN访问，访问配置文件等。命令打开编辑它： vi svnserve.conf 看到以下代码： [general] # anon-access = read # auth-access = write ... # password-db = passwd  # 密码验证文件位置，这里去掉注释即可，为同目录下passwd文件 ... # authz-db = authz      # 同上，用户验证文件，保存可以访问用户验证信息，等下会配置 ... # realm = My first repostory # 注释都去掉 realm = 一个类似Title说明，可以填任何字符，一般 reaml = ProjectName. 保存退出 然后编辑passwd vi  passwd 这里配置用户信息，在[users]下输入： [users] [...]]]></description>
		<wfw:commentRss>http://www.larro.cn/archives/39/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

