Transfer to VPS

I have moved most part of my website from Hostmonster to Burst VPS. The plan I choose has 512MB ram. When I first logged into the Debian 6 system and did a aptitude upgrade, it crashed with a message saying not having enough memory. I checked the memory usage. It was more than 300MB, 250MB of which was taken by Apache. So I decided to use Cherokee instead.

Cherokee is a fast and efficient HTTP server, and it obviously does not support Apache’s .htaccess files. Most server-side programs (well, most PHP programs) ship with such a file with some rewrite rules in it. A common set of such rules goes like

  1. Redirect /prefix/ to /prefix/index.php.
  2. Serve /prefix/blabla if this blabla is an actual file,
  3. otherwise redirect /prefix/blabla to /prefix/index.php/blabla.
These rules apply to all the PHP programs I am using, including Wordpress. Sometimes an extra “?” is needed immediately after index.php in the last rule.

How these rules can be implemented in Cherokee depends on whether the program is in a virtual server or a sub-directory of a virtual server. In most cases, this means to see if a program is in the root directory of a web site. If the program is directly in a virtual server, the first rule is covered by the directory indexes setting of the virtual server; otherwise it has to be a behavior rule of the virtual server. A simple path rule that substitutes (.*)/ to $1/index.php will do. The second rule can be implemented with a logic and of a directory and a file exists match rule, that servers static content. The third rule can be done with a regexp matching of /prefix/(.+) and substitute it with /prefix/index.php/$1. Cherokee has a Wordpress wizard which does one more rule between the first and the seond, if Wordpress is in a sub-directory of a virtual server. It set the document root to that sub-directory. And this rule is non-final.

I am also changing my gallery program from Gallery to Piwigo, because Gallery 3 is probably not very non-Apache-friendly. We will see how that works out.

comments powered by Disqus