<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[大尾巴自留地]]></title> 
<link>http://blog.daweiba.com/index.php</link> 
<description><![CDATA[大尾巴的窝]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[大尾巴自留地]]></copyright>
<item>
<link>http://blog.daweiba.com/read.php/224.htm</link>
<title><![CDATA[nginx学习教程初级篇]]></title> 
<author>大尾巴 &lt;admin@yourname.com&gt;</author>
<category><![CDATA[学习]]></category>
<pubDate>Wed, 10 Mar 2010 14:45:39 +0000</pubDate> 
<guid>http://blog.daweiba.com/read.php/224.htm</guid> 
<description>
<![CDATA[ 
	<p>一、介绍Nginx是俄罗斯人编写的十分轻量级的HTTP服务器,Nginx，它的发音为&ldquo;engine X&rdquo;， 是一个高性能的HTTP和反向代理服务器，同时也是一个IMAP/POP3/SMTP 代理服务器．<br />二、Location语法语法：location [=&#124;~&#124;~*&#124;^~] /uri/ &#123; &hellip; &#125;<br />注：<br />1、~&nbsp;&nbsp; 为区分大小写匹配<br />2、~* 为不区分大小写匹配<br />3、!~和!~*分别为区分大小写不匹配及不区分大小写不匹配<br />示例一：<br />location&nbsp; / &#123; &#125;<br />匹配任何查询，因为所有请求都以 / 开头。但是正则表达式规则将被优先和查询匹配。<br />示例二：<br />location =/ &#123;&#125;<br />仅仅匹配/<br />示例三：<br />location ~* &#92;.(gif&#124;jpg&#124;jpeg)$ ｛<br />rewrite &#92;.(gif&#124;jpg)$ /logo.png;<br />｝<br />注：不区分大小写匹配任何以gif，jpg，jpeg结尾的文件<br />三、ReWrite语法<br />last - 基本上都用这个Flag。<br />break - 中止Rewirte，不在继续匹配<br />redirect - 返回临时重定向的HTTP状态302<br />permanent - 返回永久重定向的HTTP状态301<br />1、下面是可以用来判断的表达式：<br />-f和!-f用来判断是否存在文件<br />-d和!-d用来判断是否存在目录<br />-e和!-e用来判断是否存在文件或目录<br />-x和!-x用来判断文件是否可执行<br />2、下面是可以用作判断的全局变量<br />例：http://localhost:88/test1/test2/test.php<br />$host：localhost<br />$server_port：88<br />$request_uri：http://localhost:88/test1/test2/test.php<br />$document_uri：/test1/test2/test.php<br />$document_root：D:&#92;nginx/html<br />$request_filename：D:&#92;nginx/html/test1/test2/test.php<br />四、Redirect语法<br />&nbsp;&nbsp;&nbsp; server &#123;<br />&nbsp;&nbsp;&nbsp; listen 80;<br />&nbsp;&nbsp;&nbsp; server_name start.igrow.cn;<br />&nbsp;&nbsp;&nbsp; index index.html index.php;<br />&nbsp;&nbsp;&nbsp; root html;<br />&nbsp;&nbsp;&nbsp; if ($http_host !~ &quot;^star&#92;.igrow&#92;.cn$&amp;quot [点击图片可在新窗口打开] &#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rewrite ^(.*) http://star.igrow.cn$1 redirect;<br />&nbsp;&nbsp;&nbsp; &#125;<br />&nbsp;&nbsp;&nbsp; &#125;<br />五、防盗链location ~* &#92;.(gif&#124;jpg&#124;swf)$ &#123;<br />&nbsp; valid_referers none blocked start.igrow.cn sta.igrow.cn;<br />&nbsp; if ($invalid_referer) &#123;<br />&nbsp; rewrite ^/ http://$host/logo.png;<br />&nbsp; &#125;<br />&#125;<br />六、根据文件类型设置过期时间<br />location ~* &#92;.(js&#124;css&#124;jpg&#124;jpeg&#124;gif&#124;png&#124;swf)$ &#123;<br />if (-f $request_filename) &#123;<br />&nbsp;&nbsp; expires&nbsp;&nbsp;&nbsp; 1h;<br />&nbsp;&nbsp; break;<br />&#125;<br />&#125;<br />七、禁止访问某个目录<br />location ~* &#92;.(txt&#124;doc)$&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; root /data/www/wwwroot/linuxtone/test;<br />&nbsp;&nbsp;&nbsp; deny all;<br />&#125;</p><br/>Tags - <a href="http://blog.daweiba.com/go.php/tags/nginx/" rel="tag">nginx</a>
]]>
</description>
</item><item>
<link>http://blog.daweiba.com/read.php/223.htm</link>
<title><![CDATA[apache 将php 解析为SSI]]></title> 
<author>大尾巴 &lt;admin@yourname.com&gt;</author>
<category><![CDATA[尾巴心情]]></category>
<pubDate>Wed, 10 Mar 2010 07:48:48 +0000</pubDate> 
<guid>http://blog.daweiba.com/read.php/223.htm</guid> 
<description>
<![CDATA[ 
	配置后php文件将先作为php解析<br />之后再作为ssi解析<br />&lt;!--#include file=&quot;abc.html&quot; --&gt;<br /><br /><br /># 文档目录 #<br />DocumentRoot D:/www<br />&nbsp;&nbsp;&nbsp; &lt;Directory &quot;D:/www&quot;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Options Indexes FollowSymLinks Includes<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # AddType text/html .shtml .php #加上此行无法解析php<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AddOutputFilter Includes .php<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AllowOverride All<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Order allow,deny<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Allow from all<br />&lt;/Directory&gt;
]]>
</description>
</item><item>
<link>http://blog.daweiba.com/read.php/222.htm</link>
<title><![CDATA[zend studio 7.1.1注册码及汉化包下载]]></title> 
<author>大尾巴 &lt;admin@yourname.com&gt;</author>
<category><![CDATA[学习]]></category>
<pubDate>Thu, 04 Mar 2010 10:07:54 +0000</pubDate> 
<guid>http://blog.daweiba.com/read.php/222.htm</guid> 
<description>
<![CDATA[ 
	<p>以下内容均来自网络。</p><p>Zend Studio 7.1.1 官方<a href="http://www.lisijie.org/article/235/tag/%E4%B8%8B%E8%BD%BD/" title="查看有关&ldquo;下载&rdquo;的文章">下载</a>地址：</p><p><a href="http://downloads.zend.com/studio-eclipse/7.1.1/ZendStudio-7.1.1.exe">http://downloads.zend.com/studio-eclipse/7.1.1/ZendStudio-7.1.1.exe</a></p><p>汉化包下载（汉化率超过90%）：</p><p><a href="http://www.lisijie.org/download/zs7_cn.rar">http://www.lisijie.org/download/zs7_cn.rar</a></p><p>汉化包使用方法：</p><p>解压后将里面的两个文件夹features和plugins替换你的zend studio安装目录下的对应目录，重启zend studio即可。</p><p>附Zend Studio 7.X注册码（仅供学习，请向Zend公司购买授权）：</p><p>username：lisijie_org<br />License Key：3F4F495657BF3F4A95657BF3</p>
]]>
</description>
</item><item>
<link>http://blog.daweiba.com/read.php/221.htm</link>
<title><![CDATA[一个用于同步CentOS镜像的脚本]]></title> 
<author>大尾巴 &lt;admin@yourname.com&gt;</author>
<category><![CDATA[学习]]></category>
<pubDate>Wed, 27 Jan 2010 03:39:54 +0000</pubDate> 
<guid>http://blog.daweiba.com/read.php/221.htm</guid> 
<description>
<![CDATA[ 
	<p>因为在同步时需要使用代理，可能因为代理而导致在第一次同步CentOS镜像时，或每当CentOS发布新的版本时，同步的进程总是继线退出。为了解决这个问题，写了如下一个脚本：<br /></p><div class="codeblock">[user@host ~]$ cat mon_centos.sh <br />#!/bin/bash<br />export RSYNC_PROXY=&quot;xxx.xxx.xxx.xxx:3128&quot;<br />while true<br />do <br />&nbsp; counter=`ps ax &#124; grep rsync &#124;grep centos &#124;grep -v grep &#124; wc -l`<br />&nbsp; pro_id=`ps ax &#124; grep rsync &#124;grep centos &#124;grep -v grep &#124; awk '&#123;print $1&#125;'`<br />&nbsp; case $counter in<br />&nbsp;&nbsp;&nbsp; 0)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo &quot;counter=$counter&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /usr/bin/rsync -rlptvHz --partial --exclude &quot;.~tmp~/&quot; --exclude &quot;.*&quot; rsync://mirror.chpc.utah.edu/pub/centos/ /disk4/mirror/centos<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;;<br />&nbsp;&nbsp;&nbsp; 2)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo &quot;counter=$counter&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sleep 60<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;;<br />&nbsp;&nbsp;&nbsp; *)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo &quot;counter=$counter&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sleep 60<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;;<br />&nbsp; esac<br />&nbsp; sleep 60<br />done</div><br />这个脚本或反而获取当前运行rsync进程的数量，当同步进程数量为0时，重新启动同步进程，否则sleep 60秒之后重新检测。
]]>
</description>
</item><item>
<link>http://blog.daweiba.com/read.php/220.htm</link>
<title><![CDATA[用wget 制作CentOS 镜像]]></title> 
<author>大尾巴 &lt;admin@yourname.com&gt;</author>
<category><![CDATA[学习]]></category>
<pubDate>Wed, 27 Jan 2010 02:41:41 +0000</pubDate> 
<guid>http://blog.daweiba.com/read.php/220.htm</guid> 
<description>
<![CDATA[ 
	<p>wget -c -m -np -p -q -b <a href="http://mirrors.163.com/centos/5.4/">http://mirrors.163.com/centos/5.4/</a><br /></p><p>-c 是继续传送， -m 是镜像，-np 只下载目标站点指定目录及其子目录的内容&nbsp;-p 是下载媒体文件，比如图片， -q 是安静模式， -b 是后台运行<br /><br /></p><p>绕开 robots.txt 办法：</p><p>在 $HOME/.wgetrc 中加入</p><p>robots = off</p>
]]>
</description>
</item><item>
<link>http://blog.daweiba.com/read.php/219.htm</link>
<title><![CDATA[Shell中的、、()和{} ]]></title> 
<author>大尾巴 &lt;admin@yourname.com&gt;</author>
<category><![CDATA[学习]]></category>
<pubDate>Sun, 24 Jan 2010 04:16:06 +0000</pubDate> 
<guid>http://blog.daweiba.com/read.php/219.htm</guid> 
<description>
<![CDATA[ 
	&amp;&amp;左边的命令（命令1）返回真(即返回0，成功被执行）后，&amp;&amp;右边的命令（命令2）才能够被执行；换句话说，&ldquo;如果这个命令执行成功&amp;&amp;那么执行这个命令&rdquo;。 <br /><br />&#124;&#124;则与&amp;&amp;相反。如果&#124;&#124;左边的命令（命令1）未执行成功，那么就执行&#124;&#124;右边的命令（命令2）；或者换句话说，&ldquo;如果这个命令执行失败了&#124;&#124;那么就执行这个命令。<br /><br />为了在当前shell中执行一组命令，可以用命令分隔符隔开每一个命令，并把所有的命令用圆括号()括起来。 <br /><br />如果使用&#123;&#125;来代替()，那么相应的命令将在子shell而不是当前shell中作为一个整体被执行，只有在&#123;&#125;中所有命令的输出作为一个整体被重定向时，其中的命令才被放到子shell中执行，否则在当前shell执行。<br/>Tags - <a href="http://blog.daweiba.com/go.php/tags/shell/" rel="tag">shell</a>
]]>
</description>
</item><item>
<link>http://blog.daweiba.com/read.php/218.htm</link>
<title><![CDATA[修正linux下ls输出的目录颜色,让putty用起来更舒服]]></title> 
<author>大尾巴 &lt;admin@yourname.com&gt;</author>
<category><![CDATA[学习]]></category>
<pubDate>Tue, 19 Jan 2010 10:31:36 +0000</pubDate> 
<guid>http://blog.daweiba.com/read.php/218.htm</guid> 
<description>
<![CDATA[ 
	<p>putty 是一个非常小巧的ssh客户端，但是linux 下，ls目录的默认颜色输出是深蓝色，在putty里看起来非常吃力，于是我就查了一下资料稍作了一点修改，让目录颜色开起来舒服一些。如下:</p><p>打开 /etc/profile</p><p>最后添加一行：</p><p>declare -x LS_COLORS=&quot;no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=01;32:*.sh=01;32:*.csh=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:&quot;</p>
]]>
</description>
</item><item>
<link>http://blog.daweiba.com/read.php/217.htm</link>
<title><![CDATA[实战Web2.0网站性能调优]]></title> 
<author>大尾巴 &lt;admin@yourname.com&gt;</author>
<category><![CDATA[学习]]></category>
<pubDate>Tue, 19 Jan 2010 09:03:13 +0000</pubDate> 
<guid>http://blog.daweiba.com/read.php/217.htm</guid> 
<description>
<![CDATA[ 
	<p></p><p>Web2.0网站不同于以往以静态信息为主的网站架构，以往的结构大体分为2层，一个是客户端浏览器，一个就是Web服务器；而Web2.0以动态和交互为主，一般是3层或者4层，在静态信息网站的结构上的Web服务器后端会增加应用服务器和数据库。一般会把浏览器和Web服务器归为最上一层即为web层，应用服务器为中间一层，数据库为最底层。从优化角 度来讲，越上层优化获得益处越大，优化也是从上自下而来。</p><p><span style="font-size: larger"><strong><span style="font-size: small">Web层优化：</span></strong></span></p><p>1、DNS的解析时间</p><p>这个时间就是在用户第一次访问网站的时候产生，解析时间会影响用户的访问感受，因此想要网站响应速度快，第一就是不要在DNS解析上产生问题。另外DNS的TTL时间也要考量，IE的DNS过期时间是30 分钟，TTL设置的比这个长一点就可以。另外在web服务器上使用keep-live也会减少DNS查询次数。</p><p>2、降低浏览器发起请求的数量尽量降低浏览器发起请求的数量，就是说尽量能够让浏览器缓存任何可以缓存的东西。这样当用户访问过一次后，第二次访问可能会使得发起的请求数趋近1或者等于1，如果是静态的页面则可能是0。方法包括：</p><p>1）把所有的样式表文件并为1个</p><p>2）把所有的js文件并成1个</p><p>3）图片尽量能够合成1张，这个跟以前不一样，现在大多数是adsl上网，反而是大量的零碎图片能够影响速度</p><p>4）页面布局与样式页面采用xhtml，采用div+css布局，而把样式表和xhtml文件分开，一则能够降低xhtml文件大小，二则能够&nbsp; 对样式表文件进行其他缓存处理。这里还有个ui设计的原则，ui跟系统结构一样，越简洁越好，这样整体页面代码会比较少，速度也会比较不错。</p><p>5）JavaScript文件JavaScript文件也最好放到html文件外，原因同上。</p><p>3、静态文件的优化方法</p><p>1)目前大多数的浏览器都支持gzip压缩文件，因此为文本、静态页面、样式表、JavaScript文件等可以压缩处理的文件进行压缩处理能够减少内容获取时间，一般压缩完的大小为原大小的 10-30%。这个在apache等web服务器上进行设置，笔者使用lighttpd的设置为：</p><pre><ol class="dp-cpp"><li class="alt"><span><span>server.modules&nbsp;=&nbsp;( &nbsp;</span></span></li><li><span>&nbsp;&nbsp;&nbsp;&hellip;. &nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;</span><span class="string"><span style="color: #0000ff">&quot;mod_compress&quot;</span></span><span>, &nbsp;</span></li><li><span>&nbsp;&nbsp;&nbsp;&hellip; &nbsp;</span></li><li class="alt"><span>) &nbsp;</span></li><li><span>compress.cache-dir=</span><span class="string"><span style="color: #0000ff">&quot;/usr/local/lighttpd/cache&quot;</span></span><span>&nbsp;</span></li><li class="alt"><span>compress.filetype&nbsp;=&nbsp;(</span><span class="string"><span style="color: #0000ff">&quot;text/plain&quot;</span></span><span>,&nbsp;</span><span class="string"><span style="color: #0000ff">&quot;text/html&quot;</span></span><span>,&nbsp;</span><span class="string"><span style="color: #0000ff">&quot;text/css&quot;</span></span><span>,&nbsp;</span><span class="string"><span style="color: #0000ff">&quot;text/javascript&quot;</span></span><span>)&nbsp;</span></li></ol></pre><p>2)还可以在静态文件服务器前面增加缓存服务器比如squid，进一步增强客户端的访问性能。如果有好的财力，还可以使用一些商业的CDN加速服务。</p><p>4、应用Cookie的注意事项</p><p>Cookie的应用要注意，要限制cookie的应 用域和应用的目录以及过期时间。不然如果用户是第一次访问的话，可能连一个小小的静态图片都要发送cookie到服务器，这样增加了通信负载。另外要限制 cookie的大小，一个3k的cookie能够增加延迟达到80ms。<br />提高页面速度页面由2-4个不同域名的服务器提供服务能够提高速 度，这个国外也有研究证明。比如主html文件由app.domain.com提供，样式表由style.domain.com提供，图片等由 img.domain.com提供，这样浏览器可以同时从多个服务器下载文件，速度就能够上去。但是最好不要超过4个。</p><p>5、样式表文件位置</p><p>把样式表文件放在页面的，这样能够先读取。因为在ie中有个样式表的问题，样式表如果没有加载完会影响后面的html内容的页面显示，因此虽然html文件都已经在浏览器了，但是页面还是显示不出来。</p><p>把JavaScript移到html文件末尾把JavaScript移到html文件末尾。为什么这么做呢，因为JavaScript处理的过程中会阻塞后面的页面显示，并且也会使得http请求也被阻止。笔者的网站就有过这样的例子，网站上放了一 个合作方的JavaScript，结果每次访问时候感觉页面都停滞，用户体验特别差，后来让同事处理了一下，放到末尾等页面加载完了再显示在原有位置，一 下子就好了。<br />6、尽量避免跳转尽量避免跳转比如301和302。如果必须的话，对301和302的页面添加过期头。笔者原来的单点登录就需要进行跳转，后来改进了不需要跳转，整体的速度效果就出来了。</p><p>7、移除重复的脚本要移除重复的脚本，IE会对重复的脚本发起重复的http请求，大多数网站在运营一段时间都有可能出现这个情况，笔者的网站中就经常有市场人员添加的重复的广告脚本。</p><p>8、AJAX内容AJAX内容也是可以进行缓存的，同样可以压缩和缓存异步调用的xml、json等数据。</p><p>9、对爬虫进行限制对爬虫进行限制，国内的一些爬虫非常厉害，并且不遵守robots规矩，经常有反应某某厉害爬虫把网站搞瘫的事件。怎么对爬虫进行限制呢，只能在web服务器上下功夫了，apache等服务器都能够进行限制，笔者的lighttpd限制10个并发的配置如下：&nbsp;</p><p><em>&nbsp; evasive.max-conns-per-ip = 10</em></p><p>Web层的优化目的就是极大的利用了浏览器的缓存特性，从而达到几乎是本地访问的速度，下图是笔者访问douban.com首页的效果图对比：</p><p style="text-align: center"><a href="http://images.51cto.com/files/uploadimg/20100119/0901480.jpg" target="_blank"><img class="fit-image" src="http://images.51cto.com/files/uploadimg/20100119/0901480.jpg" border="0" width="420" height="189" /></a></p><p>前一列数据是空的缓存所需要下载的文件大小和http请求数量，后面是真实访问的带cache的情况，效果特别明显。http请求减少了95%，内容cache了82%。</p><p><strong>应用程序层优化：</strong></p><p>应用服务器的优化，Php的可以采用一些优化手段比如Zend Optimizer、eAccelerator、MMCache、Zend Performance Suite等。Java的可以采用一些性能强的jdk、应用服务器，对jdk参数进行优化等等；</p><p>使用ETagETag，就像版本控制服务器中的版本号一样，每次更新后的ETag是不一样的，而浏览器处理就类似版本服务器的客户端一样，先把版本号发到服务器请求。ETag的处理过程，先是Web服务器在响应的http头中发送ETag，比如这样：</p><p><em>ETag: &quot;1111-2222-3333&quot;<br />Last-Modified: Thu, 07 Oct 2007 15:20:18 GMT</em></p><p>而浏览器如果再次请求该页面就会发送类似如下的头：</p><p><em>If-None-Match: &quot;1111-2222-3333&quot;<br />If-Modified-Since: Thu, 07 Oct 2007 15:20:18 GMT</em></p><p>此时，如果该页面没有任何变更，则web服务器会响应一个304的头，并且不需要附带页面内容给浏览器（即不需要再动态生成页面内容），这样就大大减少了服务器的处理和网路通信负载。</p><p></p><div class="tuij"><ul><li><a href="http://developer.51cto.com/art/200703/42476.htm" target="_blank"><span style="color: #464646">Web2.0时代 系统架构与六大关键问题</span></a> </li><li><a href="http://developer.51cto.com/art/200812/101270.htm" target="_blank"><span style="color: #464646">详解网站性能测试指标</span></a> </li><li><a href="http://developer.51cto.com/art/200904/120321.htm" target="_blank"><span style="color: #464646">优化DotNetNuke网站性能的10个技巧</span></a> </li><li><a href="http://developer.51cto.com/art/200905/123565.htm" target="_blank"><span style="color: #464646">Facebook图片存储架构技术全解析</span></a> </li></ul></div>同步变异步同步变异步，在Web2.0网站中经常有很复杂的处理，比如一个用户的注册还需要发邮件等操作，有时候可能还有其他的处理，这样用户的等待时间比较长，并且容易出现错误。此种情况下，把其他处理变成异步 的，从而直接把页面尽快响应给用户。笔者的一个数据上传的程序也是如此处理，一大堆数据，上传时间可能就1-2秒，而处理时间可能长的需要接近10秒（需 要在数据库中进行上千次的插入操作），而在应用服务器容器内处理耗时则更长，笔者后来改成异步处理以后，用户满意度则大幅上升。 <p></p><p><br />使用缓存，还是缓存，可能的情况下尽量使用缓存，毕竟现在内存非常便宜，用空间换取时间效率应该是非常划算的。尤其是对耗时比较长的、需要建立网络链接的，方法：采用memcached进行数据库或者常用数据的缓存；应用数据库缓冲池减少建立数据库连接的时间</p><p>采用gzip压缩动态页面可能情况下，也可以采用gzip压缩动态页面。如果服务器较多，cpu负载不高，则可以考虑对动态页面增加gzip压缩功能。</p><p>集群处理，访问压力大的时候，对应用服务器采用集群处理。</p><p>应用服务器的优化主要是减少程序处理的时间，提高运行效率。</p><p>数据库优化这个议题跟具体数据库关系比较大，议题也比较广泛，笔者就只简要列举一下：</p><p>设置专门的DBA，专门负责数据库的安装、优化；对sql进行优化采用数据库集群和复制功能分担数据库压力。</p><p>其他优化措施网站的优化涉及的方面比较多，其他方面涉及的还包括网站架构、操作系统、服务器硬件、网络设备、isp机房网络等等的调优。</p><p>工具笔者用到的工具，都是firefox插件，所以firefox是必备的了：</p><p>1、LiveHTTPHeaders (<span style="color: #0000ff">http://livehttpheaders.mozdev.org/</span>)</p><p>2、Firebug <span style="color: #0000ff">(http://getfirebug.com</span>)</p><p>3、YSlow (<span style="color: #0000ff">http://developer.yahoo.com/yslow/</span>)，要先装Firebug</p><p>4、Web Developer (<span style="color: #0000ff">http://chrispederick.com/work/web-developer/</span>)</p><p>除了这些免费的工具外，还可以采用一些商业的网站性 能监测服务。一般网站性能监测服务商都会在不同的isp设置数据采集点，然后会定期模拟浏览器的访问对网站进行访问获取各种数据，比如dsn查询时间、第 一个包获取时间、整个页面加载时间等等，然后汇总到数据中心。数据中心则可以产生性能报表、不同时间的可访问率、哪个isp容易出问题、发出警报等等。如 果预算足够的话，可以采用这个服务。国外的有keynote、ip-label等，功能比较齐全，但是服务费用比较贵而且国内的点比较少。国内近些年也开 始涌现出一些厂商，比如基调网络。笔者使用的监测系统的图例：</p><p style="text-align: center"><a href="http://images.51cto.com/files/uploadimg/20100119/0901481.jpg" target="_blank"><img style="width: 498px" class="fit-image" src="http://images.51cto.com/files/uploadimg/20100119/0901481.jpg" border="0" width="498" height="202" /></a></p><p>网站3年不同阶段的优化过程优化的原则是尽量不去优化，在未发生性能问题的时候，没有必要去专门考虑细节的性能问题，当然大的结构应该是能够适应网站不断发展变化的。笔者的网站近3年的优化过程如下：</p><p>1、开发完成，刚上线的时候，不做优化，用户量少，用了3台服务器。</p><p>2、10万用户的时候，主要对SQL进行了优化，还是3台服务器。</p><p>3、10万用户到100万的过程中，采用了AJAX等，因此开始关注JavaScript的优化手段，访问量也快速上去，因此对静态文件进行分离并优化。服务器也进行了扩展，扩展到5台服务器。</p><p>4、100万-200万用户，业务系统增加了很多，因此数据库采用了复制，程序方面应用了各种缓存处理，在数据库和程序之间增加了memcached进行数据缓存。</p><p>5、在200万用户以上，主要在程序架构上做文章，对某些服务使用了集群。另外为了监测国内不同城市、ISP的网络状况，使用了商业化的网站性能监测服务。</p><p></p><p><em>本网转载自的博客，</em></p><p><em>原文地址：</em><em><span style="color: #0033ff">http://blog.csdn.net/ynwso/archive/2010/01/12/5183191.aspx</span></em></p>
]]>
</description>
</item><item>
<link>http://blog.daweiba.com/read.php/216.htm</link>
<title><![CDATA[VMware Hyper-V 共存]]></title> 
<author>大尾巴 &lt;admin@yourname.com&gt;</author>
<category><![CDATA[学习]]></category>
<pubDate>Tue, 19 Jan 2010 08:31:49 +0000</pubDate> 
<guid>http://blog.daweiba.com/read.php/216.htm</guid> 
<description>
<![CDATA[ 
	要修改启动菜单，增加一个启动选项，令其启动时不加载Hypervisor<br /><br />cmd<br />bcdedit /copy &#123;default&#125; /d &quot;Windows 2008R2 without Hypervisor&quot;<br />//记录下显示的 guid 号<br />//后面的菜单项名称自己修改吧<br />bcdedit /set &#123;guid&#125; hypervisorlaunchtype off<br />//用上面的 guid 号 替换上面命令行中的 &#123;guid&#125;<br /><br /><br />启动菜单制作完成<br /><br />要用VMware 就进 without Hypervisor的
]]>
</description>
</item><item>
<link>http://blog.daweiba.com/read.php/215.htm</link>
<title><![CDATA[linux下apache+php安装常见问题]]></title> 
<author>大尾巴 &lt;admin@yourname.com&gt;</author>
<category><![CDATA[学习]]></category>
<pubDate>Tue, 19 Jan 2010 03:54:39 +0000</pubDate> 
<guid>http://blog.daweiba.com/read.php/215.htm</guid> 
<description>
<![CDATA[ 
	<p><strong>configure: error: Unable to find libgd.(a&#124;so)</strong></p><p>如果使用的是ubuntu或debian就很简单了，直接sudo apt-get install apache2 libapache2-mod-php5 php5 php5-gd 就基本上搞定，但是用源代码安装还是很麻烦～<br /></p><div class="code">wget <a href="http://www.boutell.com/gd/http/gd-2.0.11.tar.gz" target="_blank">http://www.boutell.com/gd/http/gd-2.0.11.tar.gz</a><br />tar zxvf gd-2.0.11.tar.gz<br />cd gd-2.0.11<br />sudo ./configure --prefix=/usr/local/gd2<br />sudo make<br />sudo make install</div><p>再php:~/:./configure &hellip;&hellip; --with-gd=/usr/local/gd2 &hellip;&hellip;<br /><br /></p><p><em><br />以下是转载的,而且都是基于yum install或者apt-get的。<br /></em></p><p>1) Configure: error: xml2-config not found. Please check your libxml2 installation.</p><p>Solutions :</p><div style="margin: 5px 20px 20px"><div class="smallfont" style="margin-bottom: 2px">Quote:</div><table border="0" cellspacing="0" cellpadding="6" width="100%"><tbody><tr><td class="alt2" style="border: 1px inset"><span style="color: #8b0000">#<strong>yum install </strong></span><span style="color: #8b0000"><strong>libxml2 </strong></span><span style="color: #8b0000"><strong>libxml2-devel </strong></span><span style="color: #8b0000"><strong>(For Redhat &amp; Fedora)</strong></span> <p><span style="color: #8b0000"><strong># aptitude install lib</strong></span><span style="color: #8b0000"><strong>xml2</strong></span><span style="color: #8b0000"><strong>-dev (For ubuntu)</strong></span></p></td></tr></tbody></table></div><p>2) Checking for pkg-config&hellip; /usr/bin/pkg-config<br />configure: error: Cannot find OpenSSL&rsquo;s &lt;evp.h&gt;</p><p>Solutions :</p><div style="margin: 5px 20px 20px"><div class="smallfont" style="margin-bottom: 2px">Quote:</div><table border="0" cellspacing="0" cellpadding="6" width="100%"><tbody><tr><td class="alt2" style="border: 1px inset">#<strong><span style="color: #8b0000">yum install </span></strong><strong><span style="color: #8b0000">openssl </span></strong><strong><span style="color: #8b0000">openssl-devel</span></strong></td></tr></tbody></table></div><p>3) Configure: error: Please reinstall the BZip2 distribution</p><p>Solutions :</p><div style="margin: 5px 20px 20px"><div class="smallfont" style="margin-bottom: 2px">Quote:</div><table border="0" cellspacing="0" cellpadding="6" width="100%"><tbody><tr><td class="alt2" style="border: 1px inset"># <strong><span style="color: #8b0000">yum install </span></strong><strong><span style="color: #8b0000">bzip2 </span></strong><strong><span style="color: #8b0000">bzip2-devel</span></strong></td></tr></tbody></table></div><p>4) Configure: error: Please reinstall the libcurl distribution -<br />easy.h should be in &lt;curl-dir&gt;/include/curl/</p><p>Solutions :</p><div style="margin: 5px 20px 20px"><div class="smallfont" style="margin-bottom: 2px">Quote:</div><table border="0" cellspacing="0" cellpadding="6" width="100%"><tbody><tr><td class="alt2" style="border: 1px inset"># <span style="color: #8b0000"><strong>yum install </strong></span><span style="color: #8b0000"><strong>curl </strong></span><span style="color: #8b0000"><strong>curl-devel (For Redhat &amp; Fedora)</strong></span> <p><span style="color: #8b0000"><strong># install libcurl4-gnutls-dev (For Ubuntu)<br /></strong></span></p></td></tr></tbody></table></div><p>5) Configure: error: libjpeg.(also) not found.</p><p>Solutions :</p><div style="margin: 5px 20px 20px"><div class="smallfont" style="margin-bottom: 2px">Quote:</div><table border="0" cellspacing="0" cellpadding="6" width="100%"><tbody><tr><td class="alt2" style="border: 1px inset"># <strong><span style="color: #8b0000">yum install </span></strong><strong><span style="color: #8b0000">libjpeg</span></strong><strong><span style="color: #8b0000"> libjpeg-devel</span></strong></td></tr></tbody></table></div><p>6) Configure: error: libpng.(also) not found.</p><p>Solutions :</p><div style="margin: 5px 20px 20px"><div class="smallfont" style="margin-bottom: 2px">Quote:</div><table border="0" cellspacing="0" cellpadding="6" width="100%"><tbody><tr><td class="alt2" style="border: 1px inset"># <strong><span style="color: #8b0000">yum install </span></strong><strong><span style="color: #8b0000">libpng </span></strong><strong><span style="color: #8b0000">libpng-devel</span></strong></td></tr></tbody></table></div><p>7) Configure: error: freetype.h not found.<br />Solutions :</p><div style="margin: 5px 20px 20px"><div class="smallfont" style="margin-bottom: 2px">Quote:</div><table border="0" cellspacing="0" cellpadding="6" width="100%"><tbody><tr><td class="alt2" style="border: 1px inset">#<strong><span style="color: #8b0000">yum install freetype-devel</span></strong></td></tr></tbody></table></div><p>8) Configure: error: Unable to locate gmp.h</p><p>Solutions :</p><div style="margin: 5px 20px 20px"><div class="smallfont" style="margin-bottom: 2px">Quote:</div><table border="0" cellspacing="0" cellpadding="6" width="100%"><tbody><tr><td class="alt2" style="border: 1px inset"># <strong><span style="color: #8b0000">yum install gmp-devel</span></strong></td></tr></tbody></table></div><p>9) Configure: error: Cannot find MySQL header files under /usr.<br />Note that the MySQL client library is not bundled anymore!</p><p>Solutions :</p><div style="margin: 5px 20px 20px"><div class="smallfont" style="margin-bottom: 2px">Quote:</div><table border="0" cellspacing="0" cellpadding="6" width="100%"><tbody><tr><td class="alt2" style="border: 1px inset"># <strong><span style="color: #8b0000">yum install mysql-devel (For Redhat &amp; Fedora)</span></strong> <p><strong><span style="color: #8b0000"># apt-get install libmysql++-dev (For Ubuntu)<br /></span></strong></p></td></tr></tbody></table></div><p>10) Configure: error: Please reinstall the ncurses distribution</p><p>Solutions :</p><div style="margin: 5px 20px 20px"><div class="smallfont" style="margin-bottom: 2px">Quote:</div><table border="0" cellspacing="0" cellpadding="6" width="100%"><tbody><tr><td class="alt2" style="border: 1px inset"># <strong><span style="color: #8b0000">yum install </span></strong><strong><span style="color: #8b0000">ncurses </span></strong><strong><span style="color: #8b0000">ncurses-devel</span></strong></td></tr></tbody></table></div><p>11) Checking for unixODBC support&hellip; configure: error: ODBC header file &lsquo;/usr/include/sqlext.h&rsquo; not found!</p><p>Solutions :</p><div style="margin: 5px 20px 20px"><div class="smallfont" style="margin-bottom: 2px">Quote:</div><table border="0" cellspacing="0" cellpadding="6" width="100%"><tbody><tr><td class="alt2" style="border: 1px inset"># <strong><span style="color: #8b0000">yum install unixODBC-devel</span></strong></td></tr></tbody></table></div><p>12) Configure: error: Cannot find pspell</p><p>Solutions :</p><div style="margin: 5px 20px 20px"><div class="smallfont" style="margin-bottom: 2px">Quote:</div><table border="0" cellspacing="0" cellpadding="6" width="100%"><tbody><tr><td class="alt2" style="border: 1px inset"># <strong><span style="color: #8b0000">yum install pspell-devel</span></strong></td></tr></tbody></table></div><p>13) configure: error: mcrypt.h not found. Please reinstall libmcrypt.</p><p>Solutions :</p><div style="margin: 5px 20px 20px"><div class="smallfont" style="margin-bottom: 2px">Quote:</div><table border="0" cellspacing="0" cellpadding="6" width="100%"><tbody><tr><td class="alt2" style="border: 1px inset"># <strong><span style="color: #8b0000">yum install libmcrypt libmcrypt-devel (For Redhat &amp; Fedora)</span></strong> <p><strong><span style="color: #8b0000"># apt-get install libmcrypt-dev<br /></span></strong></p></td></tr></tbody></table></div><p>14) Configure: error: snmp.h not found. Check your SNMP installation.</p><p>Solutions :</p><div class="smallfont" style="margin-bottom: 2px">Quote:</div># <strong><span style="color: #8b0000">yum install </span></strong><strong><span style="color: #8b0000">net-snmp</span></strong><strong><span style="color: #8b0000"> net-snmp-devel</span></strong> 
]]>
</description>
</item>
</channel>
</rss>