Archive for the ‘WordPress’ Category
-
为cos-html-cache插件增加页面(Page)、标签(Tag)和分类(Category)的静态化功能
Wordpress的cos-html-cache插件为我们系统的静态化提供了非常好的解决方案,目前的版本是2.7.3。它可以将我们首页及文章(Post)进行静态化,使得访问速度大大提高,减少了服务器端的压力。不过对于页面、标签和分类,却似乎不太起作用,至少在我的服务器环境下(IIS7.0+FastCGI)是不行的。
为了能够实现它们,我分析了一下源代码,发现功能没有开启,但是可以实现的。具体修改方法及目的如下:
找到如下三行:
- if( substr_count($_SERVER[’REQUEST_URI’], ‘.htm’) || ( SCRIPT_URI == CosSiteHome) ){
- if( substr_count($_SERVER[’REQUEST_URI’], ‘../’)) $is_buffer = false;
- if( !substr_count($buffer, ‘<!–cos-html-cache-safe-tag–>’) ) return $buffer;
将他们分别做如下处理:
- 修改为:
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) ){ - 在本行下增加:
if( substr_count($_SERVER[’REQUEST_URI’], ‘comment’)) $is_buffer = false; - 前面加上“//”注释掉本行
分别的原理及目的:
- 这个是在检测我们要静态化哪些文件,我为它增加了page、tag和category。当然,这个也和目录的模式有关,比如我的博客中,OpenSolaris的标签地址就是:http://www.priormind.com/tag/opensolaris。所以我就找到以tag开头的目录并静态化它们
- 防止评论内容被静态化
- 作者写了个函数,将singlepost(也就是单页页面)、首页都加上了一个安全标签(<!–cos-html-cache-safe-tag–>)。有这个标签的话将不被静态化。而我们需要它们静态化,所以就把这行注释掉好了
本人仅仅是尝试性修改,不保证其完全正确性。有兴趣的话大家可以试试看,呵呵。也欢迎一起交流。
-
转载:IIS FastCGI PHP 环境下搭建 WordPress
看到 Jerry Tao 在其博客上发表了一篇如何配置IIS7+FastCGI的文章,特转载过来学习。
Windows Server 2008 (SP2) + IIS 7
添加 Web 服务器角色,需要安装 CGI 扩展支持。
-
部署在Techwork.cn上的服务
利用我的域名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层,所以关键字还是要被过滤的。
在我看来,个人博客,应该具有文字功能、图片分享功能、视频分享功能、文件分享功能;而能将这些串联的,应该是网址缩短功能,或者算是Permanent Link中的一种吧~ 所以对于我的博客来说,有空的时候将会试着做做上述内容的开发,最终使得个人博客更加丰富多彩。当然,如果WP能完成上面的所有内容,那也更好啦~
- http://www.cite.techwork.cn
-
界面改版III
加入了新的favicon,优化了网站的页面,取消了wp-supercache的使用,装上了coshtmlcache,这下速度快的惊人了。
后台加入了评论控件,终于可以给评论的回复添加一个邮件提醒功能了~

博客经营进两年,虽然谈不上多好,不过记录了自己走过的岁月。虽然还有很多的不完善,虽然很懒得去弄……但坚持下来了。Twitter、围脖这类的微型博客迅猛发展着,也许很多人都觉得博客的价值越来越淡薄。但还是觉得,博客是自己最大的根据地。
还有几次,想把自己的博客扩展到可以支持相册、视频库载入的功能,但由于服务商和时间的限制,没能成型。不过以后还是会想办法集成一个统一的个人信息平台的。这样能够让更多的人加入这个圈子,做自己的主人。
开始写博,是为了向别人展示自己的空间;继续写博,是为了留下自己的回忆。
Keep writing….
-
使用WP-Super-Cache 帮你加速构建在IIS7上的WordPress博客
自从我将自己的博客搬家到海外的一个IIS7的服务器上,我发现速度比原来构建在Linux上的系统要严重慢很多。我也一直在尝试着寻找为什么WP在IIS上跑竟然如此之慢,也想改变这种状况。
将所有的日志和页面转换成静态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.php4. 打开 /wp-content/plugins/wp-super-cache/wp-cache.php 文件,找到如下内容:
[sourcecode language=“php”]function wp_cache_check_link() { global $wp_cache_link, $wp_cache_file;[/sourcecode]
将它们替换成 [sourcecode language=“php”]function wp_cache_check_link() { global $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 » -
Speed up your WordPress Blog on IIS 7 by using WP-Super-Cache
- Since I moved my Blog to an IIS 7 server outside mainland China, I found it became terribly slow than before on a LAMP (Linux+Apache+MySQL+PHP) Server. I tried to find out why my site was so slow running on IIS and wanted to change this situation.
Turning all posts and pages into static html files is a good way to extremely speed up my blog. It is common to install a plugin named “WP-Super-Cahce” for the action. But unfortunately, there was always something wrong in my WP and that plugin doesn’t work at all times. I fixed the problem today and want to share my experience with you all. Let’s start!
If you are a blogger and your blog is based on an IIS 7 environment, I think this article maybe helpful for you. I successfully installed WP-Super-Cache plugin on my IIS 7 website after solving some ugly problems. Let’s make our blog faster and faster runing on Windows Server!
Install and Configure WP-Super-Cache
There are 10 easy steps to get cached content on your IIS or Apache server under Windows:
1. Download plugin.
2. Extract it so you have a /wp-content/plugins/wp-super-cache/ directory 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.php4. Open up /wp-content/plugins/wp-super-cache/wp-cache.php and locate this:
[sourcecode language=“php”]function wp_cache_check_link() { global $wp_cache_link, $wp_cache_file;[/sourcecode]
Replace that with [sourcecode language=“php”]function wp_cache_check_link() { global $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 following rewrite rule to the web.config file located at the root folder of WordPress site. Make sure that the “WP Super Cache” rule is before the WordPress rule for pretty permalinks. Typically the <rewrite> section will look as below:
<rewrite>
<rules>
<rule name=“WP Super Cache” stopProcessing=“true”>
<match url=”^(\d{4})/(\d{2})/(.+?)/?$” ignoreCase=“false” />
<conditions>
<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 Pretty Permalinks” patternSyntax=“Wildcard”>
<match url=”*” />
<conditions>
<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 example is configured to work with WordPress permalinks that use “Month and name” format, e.g. http://wordpress/index.php/2008/12/sample-post/. If you use any other permalink format then the rule will need to be adjusted for that.
If you are using permalink style like “/%post_id%.html”, please use the following configuration:
<rule name=“WP Super Cache” stopProcessing=“true”>
<match url=”^([0–9]+).html$” ignoreCase=“false” />
<conditions>
<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 addition, 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” />
<conditions>
<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 following 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 enable WP Super Cache in the Plugins page.
9. Go to the WP Super Cache options page and enable caching.
10. If you have mod_gzip, mod_deflate, or IIS dynamic content caching enabled, make sure you don’t enable 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 source file code. If that plugin is sucessfully run, you may find the following contents at the bottom of the source code:
<!– Dynamic Page Served (once) in x.xxx seconds –>
If you see that message, Congratulations!
Make it really works for you if you meet extra problems
But in some circumstance, you will get failed. Because some of your plugin prevent WP-Super-Cache from working.
You may see that message instead:
<!– Page not cached by WP Super Cache. No closing 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 source code page, it should be some problems caused by one or more of your other plugins. They may have some conflicts!
For my site, I found my another plugin named StatPressCN is conflicted with WP-Super-Cache. You may try to deactive all your plugins and active them one by one while seeing the html source code to check which plugin is not fit for your WP-Super-Cache. After finding out the conflicts, you can decide which plugin you need more and give up another.
Try to do that and enjoy your faster blog site and your blogger life!
–Paul
Some referrence for my article:
-
Wordpress数据库转移网址变换的方法
在将数据从旧的数据库转移到新的数据库的过程中,发现一点问题,那就是所有图片还是链接到过去的域名上,而且是绝对路径。这个怎么办呢?通过简单分析wordpress数据存储结构,得出如下结论:
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里面的内容可以被新的地址所调用了。转移网站成功!
-
界面改版II
界面二度改版。。主要是解决了字体过淡不太容易看的问题,另外颜色也变成了我喜欢的蓝色调。
值得一提的是,加入了一个Head Image,里面有我和我所在的大家庭:Open Team。呵呵~
-
界面改版
最近在整理自己的blog,添加了一些插件,加入了一些新功能。另外也修改了界面,比起原来纯绿色的背景来说,蓝色的色调和得体的布局更好看一些吧,个人觉得。大家有空就常来看看,呵呵。
-
界面改版
今天将我的WordPress所使用的主题:Utom 进行了一个小小的改造,将宽度由原来的780px变成了1000px,符合了大多数现在电脑和笔记本的浏览习惯。Sohu和Sina都改版了,我也改。。。
嗯,改动不大,style.css文件改了几个参数,几个图片调整了宽度。看起来好多了
其实还是很喜欢这款主题的,简洁清晰。另外,我喜欢绿色,大自然的颜色。
Paul’s Online Services
Dynamic Tag Cloud
WP Cumulus Flash tag cloud by Roy Tanck and Luke Morton requires Flash Player 9 or better.
Recent Posts
- AIX Storage Learning 1
- 春节快乐! Happy Spring Festival!
- Sun is to the end of life
- 为cos-html-cache插件增加页面(Page)、标签(Tag)和分类(Category)的静态化功能
- How to configure Subversion in OpenSolaris
- 转载:IIS FastCGI PHP 环境下搭建 WordPress
- 在OpenSolaris下动态绑定域名
- Goodbye 2009, Hello 2010
- This Is It
- A Morse Code Exchanger
Recent Comments
- 新视界 (New Vision) » 在OpenSolaris下动态绑定域名 on 使用ZFS打造家庭廉价数据中心
- paul on Wordpress数据库转移网址变换的方法
- 知识 on Wordpress数据库转移网址变换的方法
- WP Super Cache V0.98 and IIS7 « Anders Heie on Speed up your WordPress Blog on IIS 7 by using WP-Super-Cache
- 博沈 on This Is It
- paul on 使用ZFS打造家庭廉价数据中心
- Anonymous on OpenSolaris 上的 Samba 服务器
- Anonymous on 使用ZFS打造家庭廉价数据中心
- Anonymous on OpenSolaris 上的 Samba 服务器
- Paul on 十年前和十年后的我们