Difference of try_files to rewrite in Nginx

try_files 是 Nginx 自0.6.36 新增的 directive。通常对 try_files 的理解是——它是 if (!-e $request_filename) { rewrite .* /index.php; } 的更简洁的表达。但我发现它们之间还是略有区别,主要表现在两点: 如使用 rewrite,Nginx 要求 document_root 下必须有一个 index 文件,即使我把另一个目录别名整个 document_root,但因为 Nginx 先校验 document_root 下是否有一个 index 文件,所以得放置一个空 index 文件。try_files 则没有 index 文件校验,直接去第二、第三… document_root 找对应的文件。 如使用 try_files $uri $uri/ /index.php,index.php 不能取得 get 变量,例如在 Magento 下,对 http://mydomain/catalogname?mode=list 的访问不能起效,Nginx 交付的页面是 http://mydomain/catalogname。这时必须使用 rewrite。这或许是 try_files 的一个… Continue reading Difference of try_files to rewrite in Nginx

Nice looking wqy fonts

装 Fedora 时我选 locale 是 United Kingdom,所以中文字体没有装。但能读中文,也能输入中文,大概得感谢 utf-8 之类的标准。 但英文 Fedora 显示中文的方式太别扭了,一句话里会夹杂几个字黑体,几个字宋体。我不理解为什么会这样,不研究了,用 yum install wqy* 把文泉驿字体装上就好看多了。

Linux talks to Linux using Windows languages

MyBook World Edition 基于 Linux,却是面向 Windows 用户的产品。Linux 用户怎么访问它?我一时犯傻了。 因为我早就破解了我的 MyBook World 的根密码,所以我首先想着用 root 身份、sftp 方式去访问 MyBook World。但是 Windows 用户上载到 MyBook World 的文件所有者是 www-data, root 上载上去的文件 www-data 不可写。我无从得知 www-data 的初始密码,否则我就用 www-data 身份、sftp 方式去访问 MyBook World。如果我强行修改 www-data 初始密码,万一把 MyBook World 搞瘫痪了,一个 network drive 只能当 external drive 用就不值了。 好长时间以后才想到,Fedora 自带 Connect to server -> Windows share 就可以 samba… Continue reading Linux talks to Linux using Windows languages

Varnish vs Nginx

Fedora 10 release note 提及 Varnish,据说“Varnish 是一个高性能 HTTP 加速器”,又看了一些其他网站的介绍,据说比 squid 快了好几倍。squid 是什么?没听说过。但既然同是反向代理服务器,Varnish 和 Nginx 相比如何? 我没实测,但引用别人的测试结论: 根据 Connection Times 获知 Varnish 连接速度快于 Nginx,但 Nginx 处理速度快于 Varnish,等待时间几乎一致,总时间 Nginx 要快于 Varnish 15%左右。 根据 HTML transferred 项获知大负载下 Varnish存在较多的丢包问题。 我想我还是坚持走 Nginx,并走好它。

recordset.clone is not working

我修改了一段以前写的 vba,用到了 recordset.clone,没想到由于 vba 本身的 bug,克隆并没有进行,recordset.clone 返回值仍然是原记录集的引用。我在返回值记录集进行了 recordset.delete,结果把我原本想保持不动的原记录集里的记录给删了。 那个恨啊!实在没想到 recordset.clone 只引用不克隆,害我为恢复原记录折腾了很久。我没兴趣深究原因,就当是 vba bug,就算是我调用参数配置不当,recordset.clone 克隆不成功也不能随随便便返回一个值而不抛出错误。 既然 recordset.clone 不能用,找了一个前辈 Robert Gelb 写的函数来做真正的克隆。

Goodbye, Windows

在个人桌面应用领域,我也早就想跟 Windows 说 byebye,但一直懒于重装系统。 最近换了台 64位的服务器,虽然硬件指标跟原来的比较,除了 32位升级到64位,其他方面并未有太多提升,但性能却强劲不少。既然服务器的性能能有这么大的提升,为什么不把我的桌面也提升一下?一直埋没了64位的 CPU 两年多,突然很想见识一下它在 64位操作系统下的表现。 于是下载了 Fedora x86_64,擦除了厂商的出厂分区,一键恢复 Windows 也没了,彻底投入 Linux 怀抱。

Yum update php to 5.2.x on CentOS

The current php version with CentOS is 5.1.6. Even epel repository’s php is 5.1.6. I am disappointed with epel slow up-to-date, but I found three 3rd party repositories to update php. Installation of these repositories are slightly diffferent. remi repo has php 5.2.9. To install, just run rpm -Uvh http://rpms.famillecollet.com/enterprise/5/remi/x86_64/remi-release-5-7.el5.remi.noarch.rpm atomic repo has php 5.2.9.… Continue reading Yum update php to 5.2.x on CentOS