Perfect settings for Magento on Nginx

Nginx 的文档不够详细,挺折腾人的。我经过两天181次黑匣试验,终于敢说入了 Nginx 的门。摸清 Nginx 的思路以后,才体会到它的先进性(不仅是效率上的)。php 和 nginx 搭配使用,感觉就不那么草根了,更容易借鉴 python 的 web infrastructure. 从 Apache 到 Ngnix,不容易啊。难就难在要抛弃 Apache 的思维,其实同样的配置在 Nginx 总能做到的,而且更简洁。在Apache 下,我用 symbolic link 实现 Magento 和 WordPress 等一次安装多处使用,当时我认为已经是很简单的解决方案了;转移到 Nginx 平台,多处使用连 symblic link 也省了。 以下是 Magento on Nginx 的配置,perfect,可以以不变应万变,目前我挺得意的。别笑我,这么几行配置,折腾我两天。

Bkf is not found is not true

When I tried to restore from bkf file created by Windows in-built System Tool Backup and Restore, I was not aware another colleague was accessing (read access) this file. At the last page of Restore wizard, it threw an error with a nonsense error message – “(the file name).bkf Disk 1 is not found”. The… Continue reading Bkf is not found is not true

My understanding to Nginx so far

Location directive 没有fallback 机制。因为一个 request 只能匹配一个 location,不是常规 location 的话,就是正则表达式 location。假如有两个 location blocks, location / { index index.php; } location /abc { client_max_body_size 32m; } 请别指望 index index.php  会在location /abc 生效。因为这是两个 location,只能有一个生效,另一个被忽略。 正则表达式 location 优先于常规 location 匹配(除非常规 location 使用 ^~ 或 =);常规 location 之间最长匹配优先;正则表达式 location 之间位置在前优先。 Nginx wiki 文档里关于 location 用到的 “searching stops” 这个词很不恰当,挺误导初学者的思维,让人误以为会有两个或两个以上 location同时生效。 正则表达式 location 以… Continue reading My understanding to Nginx so far

Different syntax in Nginx and Apache

今天发现一个 Nginx 和 Apache 看似细微却影响巨大的语法差异: 在 Apache 里重定向一个域名到另一个域名, RewriteRule (.*) http://destination.com/$1 [r=301,l] 而在 Nginx 里,应该多加一个斜杠/,否则 $1就多了一个斜杠。 rewrite ^/(.*) http://destination.com/$1 permanent;