<?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>PHPMan--Live and learn</title>
	<atom:link href="http://www.phpman.com.cn/feed" rel="self" type="application/rss+xml" />
	<link>http://www.phpman.com.cn</link>
	<description>不积跬步,无以至千里;不积小流,无以成江海</description>
	<lastBuildDate>Fri, 03 Feb 2012 04:00:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>一步步构建大型网站架构[转]</title>
		<link>http://www.phpman.com.cn/archives/411</link>
		<comments>http://www.phpman.com.cn/archives/411#comments</comments>
		<pubDate>Fri, 03 Feb 2012 04:00:15 +0000</pubDate>
		<dc:creator>phpman</dc:creator>
				<category><![CDATA[Others]]></category>

		<guid isPermaLink="false">http://www.phpman.com.cn/?p=411</guid>
		<description><![CDATA[天我们来谈谈一个网站一般是如何一步步来构建起系统架构的，虽然我们希望网站一开始就能有一个很好的架构，但马克思告诉我们事物是在发展中不断前进 的，网站架构也是随着业务的扩大、用户的需求不断完善的，下面是一个网站架构逐步发展的基本过程，读完后，请思考，你现在在哪个阶段。 架构演变第一步：物理分离webserver和数据库 最开始，由于某些想法，于是在互联网上搭建了一个网站，这个时候甚至有可能主机都是租借的，但由于这篇文章我们只关注架构的演变历程，因此就假设这个时候 已经是托管了一台主机，并且有一定的带宽了，这个时候由于网站具备了一定的特色，吸引了 部分人访问，逐渐你发现系统的压力越来越高，响应速度越来越慢，而这个时候比较明显的是数据库和应用互相影响，应用出问题了，数据库也很容易出现问题，而 数据库出问题的时候，应用也容易出问题，于是进入了第一步演变阶段：将应用和数据库从物理上分离，变成了两台机器，这个时候技术上没有什么新的要求，但你 发现确实起到效果了，系统又恢复到以前的响应速度了，并且支撑住了更高的流量，并且不会因为数据库和应用形成互相的影响。 看看这一步完成后系统的图示： 架构演变第二步：增加页面缓存 好景不长，随着访问的人越来越多，你发现响应速度又开始变慢了，查找原因，发现是访问数据库的操作太多，导致数据连接竞争激烈，所以响应变慢，但数据库连 接又不能开太多，否则数据库机器压力会很高，因此考虑采用缓存机制来减少数据库连接资源的竞争和对数据库读的压力，这个时候首先也许会选择采用squid 等类似的机制来将系统中相对静态的页面（例如一两天才会有更新的页面）进行缓存（当然，也可以采用将页面静态化的方案），这样程序上可以不做修改，就能够 很好的减少对webserver的压力以及减少数据库连接资源的竞争，OK，于是开始采用squid来做相对静态的页面的缓存。 看看这一步完成后系统的图示： 这一步涉及到了这些知识体系： 前端页面缓存技术，例如squid，如想用好的话还得深入掌握下squid的实现方式以及缓存的失效算法等。 架构演变第三步：增加页面片段缓存 增加了squid做缓存后，整体系统的速度确实是提升了，webserver的压力也开始下降了，但随着访问量的增加，发现系统又开始变的有些慢了，在尝 到了squid之类的动态缓存带来的好处后，开始想能不能让现在那些动态页面里相对静态的部分也缓存起来呢，因此考虑采用类似ESI之类的页面片段缓存策略，OK，于是开始采用ESI来做动态页面中相对静态的片段部分的缓存。 看看这一步完成后系统的图示： 这一步涉及到了这些知识体系： 页面片段缓存技术，例如ESI等，想用好的话同样需要掌握ESI的实现方式等； &#160; 架构演变第四步：数据缓存 在采用ESI之类的技术再次提高了系统的缓存效果后，系统的压力确实进一步降低了，但同样，随着访问量的增加，系统还是开始变慢，经过查找，可能会发现系 统中存在一些重复获取数据信息的地方，像获取用户信息等，这个时候开始考虑是不是可以将这些数据信息也缓存起来呢，于是将这些数据缓存到本地内存，改变完毕后，完全符合预期，系统的响应速度又恢复了，数据库的压力也再度降低了不少。 看看这一步完成后系统的图示： 这一步涉及到了这些知识体系： 缓存技术，包括像Map数据结构、缓存算法、所选用的框架本身的实现机制等。 &#160; 架构演变第五步： 增加webserver 好景不长，发现随着系统访问量的再度增加，webserver机器的压力在高峰期会上升到比较高，这个时候开始考虑增加一台webserver，这也是为了同时解决可用性的问题，避免单台的webserver down机的话就没法使用了，在做了这些考虑后，决定增加一台webserver，增加一台webserver时，会碰到一些问题，典型的有： 1、如何让访问分配到这两台机器上，这个时候通常会考虑的方案是Apache自带的负载均衡方案，或LVS这类的软件负载均衡方案； 2、如何保持状态信息的同步，例如用户session等，这个时候会考虑的方案有写入数据库、写入存储、cookie或同步session信息等机制等； 3、如何保持数据缓存信息的同步，例如之前缓存的用户数据等，这个时候通常会考虑的机制有缓存同步或分布式缓存； 4、如何让上传文件这些类似的功能继续正常，这个时候通常会考虑的机制是使用共享文件系统或存储等； 在解决了这些问题后，终于是把webserver增加为了两台，系统终于是又恢复到了以往的速度。 看看这一步完成后系统的图示： 这一步涉及到了这些知识体系： 负载均衡技术（包括但不限于硬件负载均衡、软件负载均衡、负载算法、linux转发协议、所选用的技术的实现细节等）、主备技术（包括但不限于ARP欺骗、linux heart-beat等）、状态信息或缓存同步技术（包括但不限于Cookie技术、UDP协议、状态信息广播、所选用的缓存同步技术的实现细节等）、共享文件技术（包括但不限于NFS等）、存储技术（包括但不限于存储设备等）。 &#160; 架构演变第六步：分库 享受了一段时间的系统访问量高速增长的幸福后，发现系统又开始变慢了，这次又是什么状况呢，经过查找，发现数据库写入、更新的这些操作的部分数据库连接的 资源竞争非常激烈，导致了系统变慢，这下怎么办呢，此时可选的方案有数据库集群和分库策 略，集群方面像有些数据库支持的并不是很好，因此分库会成为比较普遍的策略，分库也就意味着要对原有程序进行修改，一通修改实现分库后，不错，目标达到 了，系统恢复甚至速度比以前还快了。 看看这一步完成后系统的图示： 这一步涉及到了这些知识体系： 这一步更多的是需要从业务上做合理的划分，以实现分库，具体技术细节上没有其他的要求； 但同时随着数据量的增大和分库的进行，在数据库的设计、调优以及维护上需要做的更好，因此对这些方面的技术还是提出了很高的要求的。 &#160; [...]]]></description>
		<wfw:commentRss>http://www.phpman.com.cn/archives/411/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[转载]php加速 PHP APC 浅析</title>
		<link>http://www.phpman.com.cn/archives/405</link>
		<comments>http://www.phpman.com.cn/archives/405#comments</comments>
		<pubDate>Thu, 29 Dec 2011 08:56:51 +0000</pubDate>
		<dc:creator>phpman</dc:creator>
				<category><![CDATA[Others]]></category>

		<guid isPermaLink="false">http://www.phpman.com.cn/?p=405</guid>
		<description><![CDATA[php加速 PHP APC 浅析 &#160; 原文链接：http://www.perfgeeks.com/?p=298 PHP APC提供两种缓存功能，即缓存Opcode(目标文件)，我们称之为apc_compiler_cache。同时它还提供一些接口用于PHP开发人员将用户数据驻留在内存中，我们称之为apc_user_cache。我们这里主要控讨php-apc的配置。 安装PHP APC 作为测试环境，我们这里使用的是CentOS5.3（2.6.18-128.el5PAE） + Apache2.0(prefork) + php5.2。我们可以去pecl apc下载APC-3.0.19.tgz # tar -xzvf APC-3.0.19.tgz #cd APC-3.0.19 # /usr/bin/phpize # ./configure --enable-apc --enable-mmap --enable-apc-spinlocks --disable-apc-pthreadmutex #make #make install 注意:我们这里支持mmap，同时采用spinlocks自旋锁。Spinlocks是Facebook推荐使用，同时也是APC开发者推荐使用的锁机制。 PHP APC 配置参数 如果你使用的系统环境跟我的测试环境是一样的话，可以在/etc/php.d目录下创建文件apc.ini，并且相关配置写入/etc/php.d/apc.ini文件。这里，我们挑了一些常用到的配置，并进行探讨。把相关的配置放在一起解释。 apc.enabled=1 apc.enabled默认值是1，你可设成0禁用APC。如果你设置为0的时候，同样把extension=apc.so也注释掉（这样可以节约内存资源）。一旦启用了APC功能，则会缓存Opcodes到共享内存。 apc.shm_segments = 1 apc.shm_size = 30 APC既然把数据缓存在内存里面，我们就有必要对它进行内存资源限定。通过这二个配置可以限定APC可以使用的内存空间大小。 apc.shm_segments指定了使用共享内存块数，而apc.shm_size则指定了一块共享内存空间大小，单位是M。所以，允许APC使用的 内存大小应该是 apc.shm_segments * apc.shm_size = 30M。你可以调整一块共享内存的大小空间。当然,一块共享内存最大值是受操作系统限制的，即不能超过/proc/sys/kernel/shmmax大 小。否则APC创建共享内存的时候，会失败。在apc.shm_size达到了上限的时候，你可以通过设置apc.shm_segments来允许APC [...]]]></description>
		<wfw:commentRss>http://www.phpman.com.cn/archives/405/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php日历方法的使用</title>
		<link>http://www.phpman.com.cn/archives/402</link>
		<comments>http://www.phpman.com.cn/archives/402#comments</comments>
		<pubDate>Fri, 25 Nov 2011 06:58:07 +0000</pubDate>
		<dc:creator>phpman</dc:creator>
				<category><![CDATA[Others]]></category>

		<guid isPermaLink="false">http://www.phpman.com.cn/?p=402</guid>
		<description><![CDATA[我们采用的的西元（公元）历法叫格里高利历（Gregorian calendar）,在处理公元前历年时，可以转换为Julian Day表示 ；儒略日（Julian day）是指由公元前4713年1月1日，协调世界时中午12时开始所经过的天数，多为天文学家采用，用以作为天文学的单一历法 这样就保存为Julian Day天数了，方便查询排序。。 &#60;?php $jd = GregorianToJD&#40;10, 11, -4110&#41;; //公元前4110年10月11日 echo &#34;$jd\n&#34;; $jd = GregorianToJD&#40;10, 11, 2011&#41;; //公元2011年10月11日 echo &#34;$jd\n&#34;;]]></description>
		<wfw:commentRss>http://www.phpman.com.cn/archives/402/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ssh超时断开的解决方案</title>
		<link>http://www.phpman.com.cn/archives/398</link>
		<comments>http://www.phpman.com.cn/archives/398#comments</comments>
		<pubDate>Tue, 22 Nov 2011 02:29:22 +0000</pubDate>
		<dc:creator>phpman</dc:creator>
				<category><![CDATA[Others]]></category>

		<guid isPermaLink="false">http://www.phpman.com.cn/?p=398</guid>
		<description><![CDATA[当用SSH Secure Shell连接Linux时，如果几分钟没有任何操作，连接就会断开，必须重新登陆才行，每次都重复相同的操作，很是烦人，本文总结了两种解决的方法。 首选方法：配置客户端 1 linux下的ssh命令 vim /etc/ssh/ssh_config 然后找到里面的ServerAliveInterval 参数，如果没有你同样自己加一个就好了。参数意义相同，都是秒数，比如9分钟： ServerAliveInterval 540 2 SecureCRT 设置反空闲 3 Putty 启用putty keepalive putty -&#62; Connection -&#62; Seconds between keepalives ( 0 to turn off )，默认为0，改为60。 &#160; 服务端方法：更改ssh服务器的配置文件/etc/ssh/sshd_config ClientAliveInterval指定了服务器端 向客户端请求消息的时间间隔, 默认是0，不发送。而ClientAliveInterval 60表示每分钟发送一次，然后客户端响应，这样就保持长连接了。这里比较怪的地方是：不是客户端主动发起保持连接的请求(如FTerm, CTerm等),而是需要服务器先主动。 另外，至于ClientAliveCountMax，使用默认值3即可。ClientAliveCountMax表示服务器发出请求后客户端没有响应的次数达到一定值，就自动断开，正常情况下，客户端不会不响应。 ClientAliveCountMax Sets the number of client alive messages (see below) which may be sent without [...]]]></description>
		<wfw:commentRss>http://www.phpman.com.cn/archives/398/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VirtualBox: Failed to open a session for the virtual machine</title>
		<link>http://www.phpman.com.cn/archives/396</link>
		<comments>http://www.phpman.com.cn/archives/396#comments</comments>
		<pubDate>Tue, 15 Nov 2011 04:24:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Others]]></category>

		<guid isPermaLink="false">http://www.phpman.com.cn/?p=396</guid>
		<description><![CDATA[尝试 ﻿sudo /etc/init.d/vboxdrv setup 问题解决]]></description>
		<wfw:commentRss>http://www.phpman.com.cn/archives/396/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>安装vsftpd,使用pam_mysql管理ftp帐号</title>
		<link>http://www.phpman.com.cn/archives/392</link>
		<comments>http://www.phpman.com.cn/archives/392#comments</comments>
		<pubDate>Thu, 22 Sep 2011 10:41:58 +0000</pubDate>
		<dc:creator>phpman</dc:creator>
				<category><![CDATA[Others]]></category>

		<guid isPermaLink="false">http://www.phpman.com.cn/?p=392</guid>
		<description><![CDATA[一、安装 sudo apt-get install vsftpd libpam-mysql vsftpd支持三类用户登录，分别是系统用户、匿名帐户、虚拟帐户； 这里使用虚拟用户方式，并将其用mysql管理 vsftpd认证是使用pam，因此libpam-mysql是必需的 为pam创建数据库: 如pam_users，为此数据增加mysql访问权限，如用户名vsftpd &#8230; 为vsftpd创建用户表,如vsftpd，字段分别为user、password 同时也可以增加pam验证的日志表，如logs，字段分别是msg、user、pid、host、rhost、time 二、配置 编辑vsftpd的pam配置文件 sudo vi /etc/pam.d/vsftpd 内容如： auth    required        pam_mysql.so user=pam passwd=V5WYsWzfEEEGuqm7 host=localhost db=pam_users table=vsftpd usercolumn=user passwdcolumn=password crypt=3 sqllog=1 logtable=logs logmsgcolumn=msg logusercolumn=user logpidcolumn=pid loghostcolumn=host logrhostcolumn=rhost logtimecolumn=time account required        pam_mysql.so user=pam passwd=V5WYsWzfEEEGuqm7 host=localhost db=pam_users table=vsftpd usercolumn=user passwdcolumn=password crypt=3 sqllog=1 logtable=logs logmsgcolumn=msg logusercolumn=user logpidcolumn=pid [...]]]></description>
		<wfw:commentRss>http://www.phpman.com.cn/archives/392/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mysql5.5.12 在ubuntu下编译安装</title>
		<link>http://www.phpman.com.cn/archives/388</link>
		<comments>http://www.phpman.com.cn/archives/388#comments</comments>
		<pubDate>Fri, 27 May 2011 17:03:20 +0000</pubDate>
		<dc:creator>phpman</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[system related]]></category>

		<guid isPermaLink="false">http://www.phpman.com.cn/?p=388</guid>
		<description><![CDATA[今天发现MySQL源码包变了，需要使用cmake编译安装了 作个记录，备忘。。 1. 安装需要的工具 sudo apt-get install libncurses5-dev cmake 2.添加mysql组及用户 groupadd mysql useradd -r -g mysql mysql 3.安装 sudo tar zxf mysql-5.5.12.tar.gz cd mysql-5.5.12 sudo cmake . sudo make sudo make install &#160; cd /usr/local/mysql sudo chown mysql.mysql -R . sudo scripts/mysql_install_db --user=mysql 4.可选额外设置 sudo cp support-files/my-medium.cnf /etc/my.cnf sudo cp support-files/mysql.server /etc/init.d/mysqld service mysqld start [...]]]></description>
		<wfw:commentRss>http://www.phpman.com.cn/archives/388/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>安装使用MySQL-Python</title>
		<link>http://www.phpman.com.cn/archives/382</link>
		<comments>http://www.phpman.com.cn/archives/382#comments</comments>
		<pubDate>Fri, 20 May 2011 11:59:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Others]]></category>

		<guid isPermaLink="false">http://www.phpman.com.cn/?p=382</guid>
		<description><![CDATA[1).从: http://sourceforge.net/projects/mysql-python 下载MySQLdb库:最新得到的是MySQL-python-1.2.3.tar.gz #mysql-python需要setuptools,如果没有先安装它 #http://pypi.python.org/pypi/setuptools#cygwin-mac-os-x-linux-other 根据自己的python版本下载相应的setuptools-0.6c8-py2.4.egg #sh setuptools-0.6c11-py2.4.egg 2)安装 tar zxf MySQL-python-1.2.3.tar.gz cd MySQL-python-1.2.3 python setup.py build python setup.py install 3) 如果以apache cgi运行python脚本，那我们稍微修改下http.conf，添加如下 #python cgi SetEnv PYTHON_EGG_CACHE /tmp AddHandler cgi-script .cgi &#38;lt;Directory &#34;/var/www/html/python/cgi&#34;&#38;gt; Options Indexes FollowSymLinks Execcgi AllowOverride All Order allow,deny Allow from all &#38;lt;/Directory&#38;gt; PYTHON_EGG_CACHE需要一个可以的目录用来存放MySQL_Python的cache .cgi后缀作为cgi脚本运行: AddHandler cgi-script .cgi 为目录&#8221;/var/www/html/python/cgi&#8221; 添加Execcgi选项,并确保该目录可执行 4)测试脚本 #!/usr/bin/python import [...]]]></description>
		<wfw:commentRss>http://www.phpman.com.cn/archives/382/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>使用VboxManage实现宿主机到虚拟机的端口转发</title>
		<link>http://www.phpman.com.cn/archives/376</link>
		<comments>http://www.phpman.com.cn/archives/376#comments</comments>
		<pubDate>Thu, 20 Jan 2011 06:41:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Others]]></category>

		<guid isPermaLink="false">http://www.phpman.com.cn/?p=376</guid>
		<description><![CDATA[VBoxManage modifyvm &#8220;VM name&#8221; &#8211;natpf1 &#8220;guestssh,tcp,,2222,,22&#8243; With the above example, all TCP traffic arriving on port 2222 on any host interface will be forwarded to port 22 in the guest. The protocol name tcp is a mandatory attribute defining which protocol should be used for forwarding (udp could also be used). VM name : 为虚拟机名 [...]]]></description>
		<wfw:commentRss>http://www.phpman.com.cn/archives/376/feed</wfw:commentRss>
		<slash:comments>47</slash:comments>
		</item>
		<item>
		<title>才注意到php不支持无符号整型-_-!</title>
		<link>http://www.phpman.com.cn/archives/372</link>
		<comments>http://www.phpman.com.cn/archives/372#comments</comments>
		<pubDate>Fri, 08 Oct 2010 08:39:08 +0000</pubDate>
		<dc:creator>phpman</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.phpman.com.cn/?p=372</guid>
		<description><![CDATA[今天无意看手册，发现php对integer型有这样一段描述: The size of an integer is platform-dependent, although a maximum value of about two billion is the usual value (that&#8217;s 32 bits signed). 64-bit platforms usually have a maximum value of about 9E18. PHP does not support unsigned integers. Integer size can be determined using the constant PHP_INT_SIZE, and maximum value using the constant [...]]]></description>
		<wfw:commentRss>http://www.phpman.com.cn/archives/372/feed</wfw:commentRss>
		<slash:comments>163</slash:comments>
		</item>
	</channel>
</rss>

