<?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>Terrysco&#039;s Blog &#187; php</title>
	<atom:link href="http://www.terrysco.com/node/tag/php/feed" rel="self" type="application/rss+xml" />
	<link>http://www.terrysco.com</link>
	<description>仅关注于互联网行业， Linux平台开发。</description>
	<lastBuildDate>Sat, 22 May 2010 10:50:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.3</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>什么是LLMP</title>
		<link>http://www.terrysco.com/node/llmp.html</link>
		<comments>http://www.terrysco.com/node/llmp.html#comments</comments>
		<pubDate>Fri, 24 Jul 2009 18:25:56 +0000</pubDate>
		<dc:creator>terrysco</dc:creator>
				<category><![CDATA[PHP/Python/Perl/Ruby]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.terrysco.com/?p=230</guid>
		<description><![CDATA[在网站架构设计中，大家一定对 LAMP (Linux Apache Mysql Php) 不陌生。
LAMP确实是一个非常优秀的架构，秉承着自由，开放，高效，易用的设计理念。
但是，本文不打算探讨LAMP，网上有很多介绍LAMP的资料。
这里，想给大家介绍另一个在LAMP上衍生出来的，以提升性能为主要目的的开源网站架构。
1, 选择高性能 OS
首先，不难理解，任何一个server最底层的支撑还是OS，而OS的选择，主要包括 Unix, Windows server, Linux, BSD等等。
其中，开源的OS，有Linux, BSD及部分unix。从目前使用情况来看，linux还是网站首选OS之一。
但是，Linux由于其自由的特点，也给选择产生了一些不便 &#8211; 发行版太多。
现有的主流版本包括 red hat(RHEL), ubuntu, 红旗, opensuse, debian等。
其中，每一个发行版都有自己的特色，比如RHEL的稳定，ubuntu的易用，红旗的中文支持很棒等。
但要以性能为主，又兼顾稳定，易用性，以上都不是最佳选择。
这里推荐一个发行版，它是一个极限性能，加高度可定制，优化的 Linux &#8211; gentoo。
gentoo的性能优化是从kernel源码编译就开始入手了，通过选择不同的源码包，可以适应于不同的应用场景。
(不同内核介绍: http://imkenwu.javaeye.com/blog/168906 )
举个经典的例子：国内，douban.com 在定制优化过的 gentoo 上跑的web服务器最高一天支撑了 2500 万pv。
http://www.dbanotes.net/arch/douban_web_server.html
这种流量，哪怕是提供纯静态的内容，也是很恐怖的。
而支持这种大流量的，除了server本身，最关键的就是高度精简的OS了。
所以，综上所述，高性能网站推荐使用可优化，定制的 gentoo 作为载体。
2, 选择高性能 web server
Apache是 LAMP 架构最核心的 web server， 开源，模块丰富，功能强大，稳定是它的绝对优势。
在美国前100个网站中，有49%的使用apache。可见其影响力。
但是，有利有弊，apache的致命缺陷，就是多于臃肿，强大的功能，一定会带来性能上的损耗。
面对这种情形，在市场上，有一支异军突起，那就是更轻量级的 web server &#8211; lighty(lighttpd)。
官方为它定义的口号是 fly light。
它具有非常低的内存开销，cpu占用率低，效能好，以及丰富的模块支持等特点。
这让他在短时间内占据了14%以上的市场份额。并且有越来越多的人开始选择使用lighty作为前端 web server。
到这里为之，其实高性能 web server 非 lighty [...]]]></description>
		<wfw:commentRss>http://www.terrysco.com/node/llmp.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>PHPEclipse：A User Guide</title>
		<link>http://www.terrysco.com/node/php-eclipse-user-guide.html</link>
		<comments>http://www.terrysco.com/node/php-eclipse-user-guide.html#comments</comments>
		<pubDate>Fri, 19 Jun 2009 05:39:53 +0000</pubDate>
		<dc:creator>terrysco</dc:creator>
				<category><![CDATA[Linux/Shell/DB]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.anyliv.com/www.terrysco.com/?p=98</guid>
		<description><![CDATA[<p>今天看到一本好书：《PHPEclipse：A User Guide》，着重对phpeclipse这个插件进行介绍，此类资料中这个算是比较详细，三种平台都有介绍（Linux，Mac，Windows）。对Quantum DB Plug-In也有介绍，唯一&#8220;不好&#8221;的地方就是：晦涩的单词太多，不知道我辈的英文水平不是很好啊。。借助翻译工具还是硬着头皮看下来了，200多页，其中还有部分插图，花费3个小时，还算值得。</p><p>&#160;</p><p>推荐给想用eclipse做php开发的朋友，熟练后就不必使用收费的zend studio了。</p>...
]]></description>
		<wfw:commentRss>http://www.terrysco.com/node/php-eclipse-user-guide.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>PHP Architect&#8217;s Guide to PHP Security [3]</title>
		<link>http://www.terrysco.com/node/php-security-guide-3.html</link>
		<comments>http://www.terrysco.com/node/php-security-guide-3.html#comments</comments>
		<pubDate>Sun, 04 Jan 2009 08:02:39 +0000</pubDate>
		<dc:creator>terrysco</dc:creator>
				<category><![CDATA[Web Security]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.anyliv.com/www.terrysco.com/?p=75</guid>
		<description><![CDATA[<p>今天继续翻译PHP Architect's Guide to PHP Security这本书的第三章《SQL注入》。由于第二章XSS有专门的书籍介绍，以后会专门翻译，所以暂时跳过XSS，先对SQL Injection进行介绍。</p><p>SQL注入是另一种常见的漏洞（针对XSS来说），是由于对输入数据过滤不严导致的。它不像XSS是直接针对站点的用户，而是直接破坏站点本身，特别是数据库。SQL注入的目的是插入任意数据，常常是插入一条被数据库执行的SQL语句。这些潜伏的被插入语句常常执行很多操作，从获取数据到更改或删除数据库信息。</p>...
]]></description>
		<wfw:commentRss>http://www.terrysco.com/node/php-security-guide-3.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>php和python的比较</title>
		<link>http://www.terrysco.com/node/from-php-2-python.html</link>
		<comments>http://www.terrysco.com/node/from-php-2-python.html#comments</comments>
		<pubDate>Fri, 12 Dec 2008 18:23:34 +0000</pubDate>
		<dc:creator>terrysco</dc:creator>
				<category><![CDATA[PHP/Python/Perl/Ruby]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.anyliv.com/www.terrysco.com/?p=70</guid>
		<description><![CDATA[<p>python的应用现在越来越多了，想多了解点pygtk和django的东西，但只有一些php和C的基础，而python的语法还是比较独特的。接触python半年多，总结一点和php的比较以及优缺点。</p><p>首先，python的性能一直比较争议，而php本身的速度是比java的东西慢，但和db操作起来，肯定是比java的东西快很多了，这算是一个php的优势。并且php的成本较低（LAMP）应该算是很便宜的东东了，而现在支持python的服务器还不是很普遍，对机器要求也较高。下面简单看看语法。</p><p>...</p>
]]></description>
		<wfw:commentRss>http://www.terrysco.com/node/from-php-2-python.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>PHP Architect&#8217;s Guide to PHP Security [2]</title>
		<link>http://www.terrysco.com/node/php-security-guide-2.html</link>
		<comments>http://www.terrysco.com/node/php-security-guide-2.html#comments</comments>
		<pubDate>Thu, 09 Oct 2008 02:04:11 +0000</pubDate>
		<dc:creator>terrysco</dc:creator>
				<category><![CDATA[Web Security]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.anyliv.com/www.terrysco.com/?p=45</guid>
		<description><![CDATA[<p>White List Validation （白名单验证）<br />Being Careful with File Uploads （文件上传时要小心）<br />File Content Validation （文件内容验证）<br />Accessing Uploaded Data （访问上传数据）<br />The Dangers of Magic Quotes （Magic Quotes的危险性）<br />Magic Quotes Normalization （Magic Quotes正规化）<br />...</p>
]]></description>
		<wfw:commentRss>http://www.terrysco.com/node/php-security-guide-2.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Architect&#8217;s Guide to PHP Security [1]</title>
		<link>http://www.terrysco.com/node/php-security-guide-1.html</link>
		<comments>http://www.terrysco.com/node/php-security-guide-1.html#comments</comments>
		<pubDate>Fri, 26 Sep 2008 16:29:55 +0000</pubDate>
		<dc:creator>terrysco</dc:creator>
				<category><![CDATA[Web Security]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.anyliv.com/www.terrysco.com/?p=42</guid>
		<description><![CDATA[<p>这几天稍微轻松点，就再看了一次PHP Architect's Guide to PHP Security这本经典PHP安全书籍。其中整理了一些笔记之类的东西，分享给大家。都是个人组织和翻译的东西，如果有不周到的地方还请广大安全爱好者给出批评和指正。本来想逐字翻译全文，但是这是一个浩大的工程，并且学习意义不大，所以挑选一些重要的内容进行翻译和注释。</p><p style="text-align: center;"><img title="" alt="" src="http://www.terrysco.com/upload/200809261133336667.gif" onload="ResizeImage(this,520)" /></p><p>...</p>
]]></description>
		<wfw:commentRss>http://www.terrysco.com/node/php-security-guide-1.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>php抓取页面技巧</title>
		<link>http://www.terrysco.com/node/php-page-indexing.html</link>
		<comments>http://www.terrysco.com/node/php-page-indexing.html#comments</comments>
		<pubDate>Wed, 10 Sep 2008 00:20:46 +0000</pubDate>
		<dc:creator>terrysco</dc:creator>
				<category><![CDATA[PHP/Python/Perl/Ruby]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.anyliv.com/www.terrysco.com/?p=36</guid>
		<description><![CDATA[<p><br />都知道用php抓取网页文件要用到正则表达式preg_match_all和file_get_contents函数，后者用来获取文件内容，前者用来过滤出需要的内容。<br /><br />昨天抓取一个页面的时候，发现了一个有点bt的页面。里面的标点符号都替换成了图片，就是为了防止批量复制粘贴，因为这样粘贴进来的文章没有标点符号可想而知有多痛苦了。不过难不倒我们。<br /><br />虽然每个文章的标点符号是用程序随即生成图片名称的，也就是说每个图片的名字都不一样，但我们可以肯定同样的标点符号（比如逗号）图片的md5值肯定是一样的，可以测试下：<br />...</p>
]]></description>
		<wfw:commentRss>http://www.terrysco.com/node/php-page-indexing.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>[转]如何编写PHP扩展</title>
		<link>http://www.terrysco.com/node/php-extension.html</link>
		<comments>http://www.terrysco.com/node/php-extension.html#comments</comments>
		<pubDate>Mon, 15 Jan 2007 04:56:11 +0000</pubDate>
		<dc:creator>terrysco</dc:creator>
				<category><![CDATA[PHP/Python/Perl/Ruby]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.terrysco.com/?p=247</guid>
		<description><![CDATA[原文地址：http://blog.csdn.net/taft/archive/2006/02/10/596291.aspx
PHP取得成功的一个主要原因之一是她拥有大量的可用扩展。web开发者无论有何种需求，这种需求最有可能在PHP发行包里找到。PHP发行包包括支持各种数据库，图形文件格式，压缩，XML技术扩展在内的许多扩展。
扩展API的引入使PHP3取得了巨大的进展，扩展API机制使PHP开发社区很容易的开发出几十种扩展。现在，两个版本过去了，API仍然和PHP3时的非常相似。扩展主要的思想是：尽可能的从扩展编写者那里隐藏PHP的内部机制和脚本引擎本身，仅仅需要开发者熟悉API。
有两个理由需要自己编写PHP扩展。第一个理由是：PHP需要支持一项她还未支持的技术。这通常包括包裹一些现成的C函数库，以便提供PHP接口。例如，如果一个叫FooBase的数据库已推出市场，你需要建立一个PHP扩展帮助你从PHP里调用FooBase的C函数库。这个工作可能仅由一个人完成，然后被整个PHP社区共享（如果你愿意的话）。第二个不是很普遍的理由是：你需要从性能或功能的原因考虑来编写一些商业逻辑。
如果以上的两个理由都和你没什么关系，同时你感觉自己没有冒险精神，那么你可以跳过本章。
本章教你如何编写相对简单的PHP扩展，使用一部分扩展API函数。对于大多数打算开发自定义PHP扩展开发者而言，它含概了足够的资料。学习一门编程课程的最好方法之一就是动手做一些极其简单的例子，这些例子正是本章的线索。一旦你明白了基础的东西，你就可以在互联网上通过阅读文挡、原代码或参加邮件列表新闻组讨论来丰富自己。因此，本章集中在让你如何开始的话题。在UNIX下一个叫ext_skel的脚本被用于建立扩展的骨架，骨架信息从一个描述扩展接口的定义文件中取得。因此你需要利用UNIX来建立一个骨架。Windows开发者可以使用Windows ext_skel_win32.php代替ext_skel。
然而，本章关于用你开发的扩展编译PHP的指导仅涉及UNIX编译系统。本章中所有的对API的解释与UNIX和Windows下开发的扩展都有联系。
当你阅读完这章，你能学会如何
☞ 建立一个简单的商业逻辑扩展。
☞ .建议个C函数库的包裹扩展，尤其是有些标准C文件操作函数比如fopen()
 
快速开始 
 
本节没有介绍关于脚本引擎基本构造的一些知识，而是直接进入扩展的编码讲解中，因此不要担心你无法立刻获得对扩展整体把握的感觉。假设你正在开发一个网站，需要一个把字符串重复n次的函数。下面是用PHP写的例子：
function self_concat($string, $n)
{
$result = &#8220;&#8221;;
for ($i = 0; $i &#60; $n; $i++) {
$result .= $string;
}
return $result;
}
self_concat(&#8221;One&#8221;, 3) returns &#8220;OneOneOne&#8221;.
self_concat(&#8221;One&#8221;, 1) returns &#8220;One&#8221;.
假设由于一些奇怪的原因，你需要时常调用这个函数，而且还要传给函数很长的字符串和大值n。这意味着在脚本里有相当巨大的字符串连接量和内存重新分配过程，以至显著地降低脚本执行速度。如果有一个函数能够更快地分配大量且足够的内存来存放结果字符串，然后把$string重复n次，就不需要在每次循环迭代中分配内存。
为扩展建立函数的第一步是写一个函数定义文件，该函数定义文件定义了扩展对外提供的函数原形。该例中，定义函数只有一行函数原形self_concat() :
string self_concat(string str, int n)
函数定义文件的一般格式是一个函数一行。你可以定义可选参数和使用大量的PHP类型，包括: bool, float, int, array等。
保存为myfunctions.def文件至PHP原代码目录树下。
该是通过扩展骨架(skeleton)构造器运行函数定义文件的时机了。该构造器脚本叫ext_skel，放在PHP原代码目录树的ext/目录下（PHP原码主目录下的README.EXT_SKEL提供了更多的信息）。假设你把函数定义保存在一个叫做myfunctions.def的文件里，而且你希望把扩展取名为myfunctions，运行下面的命令来建立扩展骨架
./ext_skel &#8211;extname=myfunctions &#8211;proto=myfunctions.def
这个命令在ext/目录下建立了一个myfunctions/目录。你要做的第一件事情也许就是编译该骨架，以便编写和测试实际的C代码。编译扩展有两种方法：
☞  作为一个可装载模块或者DSO（动态共享对象）
☞  静态编译到PHP
因为第二种方法比较容易上手，所以本章采用静态编译。如果你对编译可装载扩展模块感兴趣，可以阅读PHP原代码根目录下的README.SELF-CONTAINED_EXTENSIONS文件。为了使扩展能够被编译，需要修改扩展目录ext/myfunctions/下的config.m4文件。扩展没有包裹任何外部的C库，你需要添加支持&#8211;enable-myfunctions配置开关到PHP编译系统里（–with-extension 开关用于那些需要用户指定相关C库路径的扩展）。可以去掉自动生成的下面两行的注释来开启这个配置。
PHP_ARG_ENABLE(myfunctions, whether to enable myfunctions support,
[ --enable-myfunctions                Include myfunctions support])
现在剩下的事情就是在PHP原代码树根目录下运行./buildconf，该命令会生成一个新的配置脚本。通过查看./configure &#8211;help输出信息，可以检查新的配置选项是否被包含到配置文件中。现在，打开你喜好的配置选项开关和&#8211;enable-myfunctions重新配置一下PHP。最后的但不是最次要的是，用make来重新编译PHP。
ext_skel应该把两个PHP函数添加到你的扩展骨架了：打算实现的self_concat()函数和用于检测myfunctions 是否编译到PHP的confirm_myfunctions_compiled()函数。完成PHP的扩展开发后，可以把后者去掉。
&#60;?php
print confirm_myfunctions_compiled(&#8221;myextension&#8221;);
?&#62;
运行这个脚本会出现类似下面的输出：
&#8220;Congratulations! [...]]]></description>
		<wfw:commentRss>http://www.terrysco.com/node/php-extension.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php，perl和python杂谈</title>
		<link>http://www.terrysco.com/node/about-php-perl-python.html</link>
		<comments>http://www.terrysco.com/node/about-php-perl-python.html#comments</comments>
		<pubDate>Thu, 23 Nov 2006 19:20:53 +0000</pubDate>
		<dc:creator>terrysco</dc:creator>
				<category><![CDATA[PHP/Python/Perl/Ruby]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.anyliv.com/www.terrysco.com/?p=14</guid>
		<description><![CDATA[<p>先说perl，这是个脚本语言，不过它的功能并不仅限于此，它是一门功能很强大的语言，古老的cgi用perl可以很好的胜任，但是有一部分的perl程序员转向python了，原因是perl语言本身有一些令人迷惑的地方，就连创建perl语言的人都说不清楚。 我刚开始接触perl的时候看到对变量的命名规则就有很多，@,$等等。。自己也说不上这样做的好处跟坏处，总之觉得perl的效率还是可以的，尤其是其强大的正则表达式实现机制和文本操作能力，所以做linux的运维者学习perl是很有助于工作的。（个人意见）</p>...
]]></description>
		<wfw:commentRss>http://www.terrysco.com/node/about-php-perl-python.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>［转载］优化PHP代码的建议</title>
		<link>http://www.terrysco.com/node/php-optimize.html</link>
		<comments>http://www.terrysco.com/node/php-optimize.html#comments</comments>
		<pubDate>Thu, 12 Oct 2006 21:16:48 +0000</pubDate>
		<dc:creator>terrysco</dc:creator>
				<category><![CDATA[PHP/Python/Perl/Ruby]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.anyliv.com/www.terrysco.com/?p=13</guid>
		<description><![CDATA[<p><br /><br />terrysco发布于2006-10-27 14:37:15&#160;&#160; 分类:Programming&#160;&#160; 评论:(0)个&#160;&#160; 引用:0&#160;&#160; 浏览:218次<br /><br />1. If a method can be static, declare it static. Speed improvement is by a factor of 4. 如果一个方法可静态化，就对它做静态声明。速率可提升至4倍。<br />...</p>
]]></description>
		<wfw:commentRss>http://www.terrysco.com/node/php-optimize.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
