Archive for the ‘WordPress’ Category

  • 为cos-html-cache插件增加页面(Page)、标签(Tag)和分类(Category)的静态化功能

    Date: 2010.01.16 | Category: In My Opinion, WordPress | Response: 0

    Wordpress的cos-html-cache插件为我们系统的静态化提供了非常好的解决方案,目前的版本是2.7.3。它可以将我们首页及文章(Post)进行静态化,使得访问速度大大提高,减少了服务器端的压力。不过对于页面、标签和分类,却似乎不太起作用,至少在我的服务器环境下(IIS7.0+FastCGI)是不行的。

    为了能够实现它们,我分析了一下源代码,发现功能没有开启,但是可以实现的。具体修改方法及目的如下:

    找到如下三行:

    1. if( substr_count($_SERVER[’REQUEST_URI’], ‘.htm’) || ( SCRIPT_URI == CosSiteHome) ){
    2. if(  substr_count($_SERVER[’REQUEST_URI’], ‘../’))  $is_buffer = false;
    3. if( !substr_count($buffer, ‘<!–cos-html-cache-safe-tag–>’) ) return  $buffer;

    将他们分别做如下处理:

    1. 修改为:
      if( strpos($_SERVER[’REQUEST_URI’], ‘page’)==1 || strpos($_SERVER[’REQUEST_URI’], ‘tag’)==1 || strpos($_SERVER[’REQUEST_URI’], ‘category’)==1 || substr_count($_SERVER[’REQUEST_URI’], ‘.htm’) || ( SCRIPT_URI == CosSiteHome) ){
    2. 在本行下增加:
      if(  substr_count($_SERVER[’REQUEST_URI’], ‘comment’))  $is_buffer = false;
    3. 前面加上“//”注释掉本行

    分别的原理及目的:

    1. 这个是在检测我们要静态化哪些文件,我为它增加了page、tag和category。当然,这个也和目录的模式有关,比如我的博客中,OpenSolaris的标签地址就是:http://www.priormind.com/tag/opensolaris。所以我就找到以tag开头的目录并静态化它们
    2. 防止评论内容被静态化
    3. 作者写了个函数,将singlepost(也就是单页页面)、首页都加上了一个安全标签(<!–cos-html-cache-safe-tag–>)。有这个标签的话将不被静态化。而我们需要它们静态化,所以就把这行注释掉好了

    本人仅仅是尝试性修改,不保证其完全正确性。有兴趣的话大家可以试试看,呵呵。也欢迎一起交流。

    • Share/Bookmark
  • 转载:IIS FastCGI PHP 环境下搭建 WordPress

    Date: 2010.01.12 | Category: Learn from Others, Web Back-end, WordPress | Response: 0

    看到 Jerry Tao 在其博客上发表了一篇如何配置IIS7+FastCGI的文章,特转载过来学习。

    Win­dows Server 2008 (SP2) + IIS 7
    添加 Web 服务器角色,需要安装 CGI 扩展支持。

    image

    Read the rest of this entry »

    • Share/Bookmark
  • 部署在Techwork.cn上的服务

    Date: 2009.09.21 | Category: WordPress | Response: 0

    利用我的域名Techwork.cn,我尝试部署了几个有意思的网络服务。

    • http://www.cite.techwork.cn
      这是一个可以完成本科生、硕士生、博士生论文中参考文献格式化的小工具。我们在写毕业论文的时候,一定要附加上参考文献;而参考文献的书写规则每次都需要对照。使用这个工具,就能够节省查阅参考文献写法的时间,并为使用者提供了各种参考文献的格式。
    • http://link.techwork.cn
      这是一个类似于tinyurl.com和bit.ly那样的网址缩短服务。在很多时候,我们可以通过缩短网址来向twitter等限制字符数量的留言中传入网址;另外,我们也可以通过网址缩短来让某个地址更富有网络意义,给它一个更加好记的名字。参考了作者的源码,发现作者1.0版和2.0版中间算法和结构都有很大变化,而我喜欢2.0的结构、1.0的算法,所以稍加改动,行程了现在这个样子。今后打算用ASP.net实现它,并开源。
    • http://www.tube.techwork.cn
      这是一个视频分享站。我们经常用手机来记录一些事情,用这个视频分享站来存储它们、展示它们,确实不错。特别是以后可以和博客相结合~呵呵~不过感觉这个项目开发的还是有点糙~~虽然人家也花了不少时间吧~ 以后有空在人家基础上做个更适合自己用的 ^_^
    • http://www.file.techwork.cn
      这就是为了和朋友之间传输文件所使用的。使用FTP上传,http多线程下载。配合以上面网址缩短,就更完美了~
    • http://www.lab.techwork.cn
      遇到GFW了么?可以暂解燃眉之急。不过因为没有走https层,所以关键字还是要被过滤的。

    在我看来,个人博客,应该具有文字功能、图片分享功能、视频分享功能、文件分享功能;而能将这些串联的,应该是网址缩短功能,或者算是Per­ma­nent Link中的一种吧~ 所以对于我的博客来说,有空的时候将会试着做做上述内容的开发,最终使得个人博客更加丰富多彩。当然,如果WP能完成上面的所有内容,那也更好啦~

    • Share/Bookmark
  • 界面改版III

    Date: 2009.09.13 | Category: In My Opinion, WordPress | Response: 4

    加入了新的favicon,优化了网站的页面,取消了wp-supercache的使用,装上了coshtmlcache,这下速度快的惊人了。

    后台加入了评论控件,终于可以给评论的回复添加一个邮件提醒功能了~

    image

    博客经营进两年,虽然谈不上多好,不过记录了自己走过的岁月。虽然还有很多的不完善,虽然很懒得去弄……但坚持下来了。Twi­tter、围脖这类的微型博客迅猛发展着,也许很多人都觉得博客的价值越来越淡薄。但还是觉得,博客是自己最大的根据地。

    还有几次,想把自己的博客扩展到可以支持相册、视频库载入的功能,但由于服务商和时间的限制,没能成型。不过以后还是会想办法集成一个统一的个人信息平台的。这样能够让更多的人加入这个圈子,做自己的主人。

    开始写博,是为了向别人展示自己的空间;继续写博,是为了留下自己的回忆。

    Keep wri­ting….

    • Share/Bookmark
  • 使用WP-Super-Cache 帮你加速构建在IIS7上的WordPress博客

    Date: 2009.04.26 | Category: WordPress | Response: 0

    自从我将自己的博客搬家到海外的一个IIS7的服务器上,我发现速度比原来构建在Linux上的系统要严重慢很多。我也一直在尝试着寻找为什么WPIIS上跑竟然如此之慢,也想改变这种状况。

    将所有的日志和页面转换成静态html格式不失为一种加速博客很好的办法,通常我们都为我们的WordPress博客加装“WP-Super-Cache”插件。但很不幸,我在自己的主机上一直没用配置这个插件成功,总是遇到一些问题。不过今天我解决了问题,也在此和朋友们分享解决的经验。

    如果你是一个blogger,并且你的博客系统是基于WordPress加上IIS7,那么我的这篇文章一定会对你有所帮助的。在解决了那些非常麻烦的问题后,我终于成功的在我的博客上加装了WP-Super-Cache插件。让我们用这个插件来加速我们的博客吧!

    具体怎么做呢?来看看我的步骤。

    安装和配置部分

    通过10步就可以完成配置:

    1. 下载这个插件(这里就不多废话了,后台有插件搜索的地方,直接下载即可)

    2. 将插件解压到 /wp-content/plugins/wp-super-cache/ 目录下

    3. 将 /wp-content/plugins/wp-super-cache/wp-cache-phase1.php 文件复制到
    /wp-content/advanced-cache.php

    4. 打开 /wp-content/plugins/wp-super-cache/wp-cache.php 文件,找到如下内容:
    [sou­r­ce­code language=“php”]function wp_cache_check_link() { glo­bal $wp_cache_link, $wp_cache_file;[/sourcecode]
    将它们替换成 [sou­r­ce­code language=“php”]function wp_cache_check_link() { glo­bal $wp_cache_link, $wp_cache_file; if ( file_exists($wp_cache_link) ) return true; else { echo “advanced-cache.php does not exist”; echo “Create it by copying $wp_cache_file to $wp_cache_link on your server”; return false; } [/sourcecode] Read the rest of this entry »

    • Share/Bookmark
  • Speed up your WordPress Blog on IIS 7 by using WP-Super-Cache

    Date: 2009.04.26 | Category: WordPress | Response: 1

      Since I moved my Blog to an IIS 7 server outside main­land China, I found it became ter­ri­bly slow than before on a LAMP (Linux+Apache+MySQL+PHP) Server. I tried to find out why my site was so slow run­ning on IIS and wan­ted to change this situation.

    Tur­ning all posts and pages into sta­tic html files is a good way to ext­re­mely speed up my blog. It is common to install a plu­gin named “WP-Super-Cahce” for the action. But unfo­r­tu­na­tely, there was always some­thing wrong in my WP and that plu­gin doesn’t work at all times. I fixed the pro­blem today and want to share my expe­rience with you all. Let’s start!

    If you are a blo­g­ger and your blog is based on an IIS 7 envi­ron­ment, I think this arti­cle maybe helpful for you. I succe­ssfu­lly insta­lled WP-Super-Cache plu­gin on my IIS 7 website after solving some ugly pro­blems. Let’s make our blog faster and faster runing on Win­dows Server!

    Install and Con­fi­gure WP-Super-Cache

    There are 10 easy steps to get cached con­tent on your IIS or Apa­che server under Windows:

    1. Down­load plugin.

    2. Ext­ract it so you have a /wp-content/plugins/wp-super-cache/ dire­ctory with all the files (like wp-cache.php) in there.

    3. Copy /wp-content/plugins/wp-super-cache/wp-cache-phase1.php to
        /wp-content/advanced-cache.php

    4. Open up /wp-content/plugins/wp-super-cache/wp-cache.php and locate this:
        [sou­r­ce­code language=“php”]function wp_cache_check_link() { glo­bal $wp_cache_link, $wp_cache_file;[/sourcecode]
        Replace that with [sou­r­ce­code language=“php”]function wp_cache_check_link() { glo­bal $wp_cache_link, $wp_cache_file; if ( file_exists($wp_cache_link) ) return true; else { echo “advanced-cache.php does not exist”; echo “Create it by copying $wp_cache_file to $wp_cache_link on your server”; return false; } [/sourcecode]

    6. Add the follo­wing rew­rite rule to the web.config file loca­ted at the root folder of Wor­dP­ress site. Make sure that the “WP Super Cache” rule is before the Wor­dP­ress rule for pre­tty per­ma­links. Typi­ca­lly the <rew­rite> section will look as below:

    <rew­rite>
    <rules>
      <rule name=“WP Super Cache” stopProcessing=“true”>
        <match url=”^(\d{4})/(\d{2})/(.+?)/?$” ignoreCase=“false” />
        <con­di­tions>
          <add input=”{REQUEST_METHOD}” negate=“true” pattern=“POST” ignoreCase=“false” />
          <add input=”{QUERY_STRING}” negate=“true” pattern=”.*=.*” ignoreCase=“false” />
          <add input=”{QUERY_STRING}” negate=“true”
                    pattern=”.*attachment_id=.*” ignoreCase=“false” />
          <add input=”{HTTP_COOKIE}” negate=“true”
                   pattern=”^.*(comment_author_|wordpress|wp-postpass_).*$” ignoreCase=“false” />
          <add
            input=”{DOCUMENT_ROOT}\wp-content\cache\supercache\{HTTP_HOST}\{R:1}\{R:2}\{R:3}\index.html”
            matchType=“IsFile” />
        </conditions>
        <action type=“Rewrite”
             url=“wp-content/cache/supercache/{HTTP_HOST}/{R:1}/{R:2}/{R:3}/index.html” />
      </rule>

      <rule name=“Wordpress Pre­tty Per­ma­links” patternSyntax=“Wildcard”>
        <match url=”*” />
        <con­di­tions>
          <add input=”{REQUEST_FILENAME}” matchType=“IsFile” negate=“true” />
          <add input=”{REQUEST_FILENAME}” matchType=“IsDirectory” negate=“true” />
        </conditions>
        <action type=“Rewrite” url=“index.php” />
      </rule>
    </rules>
    </rewrite>

    Note: this rule exa­mple is con­fi­gu­red to work with Wor­dP­ress per­ma­links that use “Month and name” for­mat, e.g. http://wordpress/index.php/2008/12/sample-post/. If you use any other per­ma­link for­mat then the rule will need to be adju­sted for that.

    If you are using per­ma­link style like “/%post_id%.html”, please use the follo­wing configuration:

    <rule name=“WP Super Cache” stopProcessing=“true”>
        <match url=”^([0–9]+).html$” ignoreCase=“false” />
        <con­di­tions>
            <add input=”{REQUEST_METHOD}” negate=“true” pattern=“POST” ignoreCase=“false” />
            <add input=”{QUERY_STRING}” negate=“true” pattern=”.*=.*” ignoreCase=“false” />
            <add input=”{QUERY_STRING}” negate=“true”
                      pattern=”.*attachment_id=.*” ignoreCase=“false” />
            <add input=”{HTTP_COOKIE}” negate=“true”
                     pattern=”^.*(comment_author_|wordpress|wp-postpass_).*$” ignoreCase=“false” />
            <add
              input=”{DOCUMENT_ROOT}\wp-content\cache\supercache\{HTTP_HOST}\{R:1}.html\index.html”
              matchType=“IsFile” />
        </conditions>
        <action type=“Rewrite” url=“wp-content/cache/supercache/{HTTP_HOST}/{R:1}.html/index.html” />
    </rule>

    In addi­tion, if you want to cache your front page like index.php, please add an rule in the front of “WP Super Cache” rule, just like this:

    <rule name=“WP Super Cache Index Page” stopProcessing=“true”>
        <match url=“index.php” ignoreCase=“false” />
        <con­di­tions>
            <add input=”{REQUEST_METHOD}” negate=“true” pattern=“POST” ignoreCase=“false” />
            <add input=”{QUERY_STRING}” negate=“true” pattern=”.*=.*” ignoreCase=“false” />
            <add input=”{QUERY_STRING}” negate=“true”
                      pattern=”.*attachment_id=.*” ignoreCase=“false” />
            <add input=”{HTTP_COOKIE}” negate=“true”
                     pattern=”^.*(comment_author_|wordpress|wp-postpass_).*$” ignoreCase=“false” />
            <add
              input=”{DOCUMENT_ROOT}\wp-content\cache\supercache\{HTTP_HOST}\index.html”
              matchType=“IsFile” />
        </conditions>
        <action type=“Rewrite” url=“wp-content/cache/supercache/{HTTP_HOST}/index.html” />
    </rule>

    7. Add the follo­wing line into the wp-config.php file above the “require_once(ABSPATH.’wp-settings.php’);” line:

    define( ‘WP_CACHE’, true );

    8. Log into your dashboard and ena­ble WP Super Cache in the Plu­gins page.

    9. Go to the WP Super Cache options page and ena­ble caching.

    10. If you have mod_gzip, mod_deflate, or IIS dyna­mic con­tent caching ena­bled, make sure you don’t ena­ble Super Cache gzip because it’s already being done on the server level (which is better, anyway! :) )

    After that 10 steps, you may find your blog become faster than before. Please open a post and see the sou­rce file code. If that plu­gin is suce­ssfu­lly run, you may find the follo­wing con­tents at the bottom of the sou­rce code:

    <!– Dyna­mic Page Served (once) in x.xxx seconds –>

    If you see that message, Congratulations!

    Make it rea­lly works for you if you meet extra problems

    But in some cir­cu­mstance, you will get fai­led. Because some of your plu­gin prevent WP-Super-Cache from working.

    You may see that message instead:

    <!– Page not cached by WP Super Cache. No clo­sing HTML tag. Check your theme. –>

    Don’t worry about your theme, it may not your theme’s fault. If you’ve seen “</html>” in that sou­rce code page, it should be some pro­blems cau­sed by one or more of your other plu­gins. They may have some conflicts!

    For my site, I found my ano­ther plu­gin named Sta­tP­re­ssCN is con­fli­cted with WP-Super-Cache. You may try to dea­ctive all your plu­gins and active them one by one while seeing the html sou­rce code to check which plu­gin is not fit for your WP-Super-Cache. After fin­ding out the con­fli­cts, you can decide which plu­gin you need more and give up another.

    Try to do that and enjoy your faster blog site and your blo­g­ger life!

    –Paul

     

    Some refer­rence for my article:

    • Share/Bookmark
  • Wordpress数据库转移网址变换的方法

    Date: 2009.03.19 | Category: WordPress | Response: 2

    在将数据从旧的数据库转移到新的数据库的过程中,发现一点问题,那就是所有图片还是链接到过去的域名上,而且是绝对路径。这个怎么办呢?通过简单分析wor­dp­ress数据存储结构,得出如下结论:

    1、存储日志文件的table是:prefix_posts。其中,prefix是在安装wordpress选择的数据库前缀名;

    2、在prefix_posts这个表中,有两个列与原先的域名有关,一个是:post_content,这个用来存储文本内容,也就是日志的html代码;另一列是guid,存储唯一识别码(跟网址绝对路径有关)。

    3、我们要执行在mysql数据库中替换字符串的过程。其sql语句如下:

    update TABLE set COLUMN=replace(COLUMN,‘STRING1’,‘STRING2’)
    其中,TABLE代表要操作的表格,COLUMN是要替换的列名,执行将STRING1替换成为STRING2

    对于本例我们应该如下做:

    update prefix_posts set prefix_content=replace(post_content,‘original_url_address’,‘present_url_address’)

    update prefix_posts set guid=replace(guid,‘original_url_address’,‘present_url_address’)

    这样,就会发现存储在/uploads里面的内容可以被新的地址所调用了。转移网站成功!

    • Share/Bookmark
  • 界面改版II

    Date: 2008.12.04 | Category: WordPress | Response: 3

    界面二度改版。。主要是解决了字体过淡不太容易看的问题,另外颜色也变成了我喜欢的蓝色调。

    值得一提的是,加入了一个Head Image,里面有我和我所在的大家庭:Open Team。呵呵~

    image

    • Share/Bookmark
  • 界面改版

    Date: 2008.08.30 | Category: WordPress | Response: 2

    最近在整理自己的blog,添加了一些插件,加入了一些新功能。另外也修改了界面,比起原来纯绿色的背景来说,蓝色的色调和得体的布局更好看一些吧,个人觉得。大家有空就常来看看,呵呵。

    image

    • Share/Bookmark
  • 界面改版

    Date: 2008.07.14 | Category: WordPress | Response: 0

    今天将我的WordPress所使用的主题:Utom 进行了一个小小的改造,将宽度由原来的780px变成了1000px,符合了大多数现在电脑和笔记本的浏览习惯。Sohu和Sina都改版了,我也改。。。

    嗯,改动不大,style.css文件改了几个参数,几个图片调整了宽度。看起来好多了 :-)

    其实还是很喜欢这款主题的,简洁清晰。另外,我喜欢绿色,大自然的颜色。

    • Share/Bookmark
Page 1 of 212

Paul’s Online Services

Dynamic Tag Cloud

Recent Posts

Recent Comments

Tags

2008.11.Trip-of-GuangXi ASP.net C++ China Chrome css dotNet FCGuoAn Firefox Football gmail IBM IE IIS IT Association Joke Microsoft music mysql NLP Nokia ntfs NumPy OpenSolaris open source Open Team php pidgin PKUSS Python Python Challenge qq Samba SciPy Learning shell solaris SQL SUN Thunderbird Travel web host Win 7 WordPress X11 zfs