How to configure nginx to run Kohana on Ubuntu
As a web developer I’ve been using Apache for a long long time. Recently though, I’ve started to move away from Apache in favor of nginx (pronounced “engine-X”). It’s not that I really need its strength, it’s just that I wanted to learn something new to break my box.
It’s fairly simple to set up and get nginx running with FastCGI and MySQL on Ubuntu – a very well-written tutorial can be read on HowtoForge, which should take you less than 15 minutes for everything. In this article therefore I will only write about how to configure nginx to actually run a Kohana-powered site, with virtual host and rewriting and such. If you’re not familiar with Kohana, take a look at my article here.
The prerequisites
- I have my Kohana-power site located under
/home/phoenixheart/www/my-kohana/directory with proper permission set (owner being www-data, that is). - nginx has been set up properly and listening on port 80, with the configuration directory being
/etc/nginx/ - I want my site to be locally accessible via my-kohana.dev. Any requests to www.my-kohana.dev should be permanently redirected to my-kohana.dev – which is also called “force non-www”.
- I want to have neat URL rewriting without “index.php”, for example
index.php?controller=product&function=get&id=1should be rewritten into/product/get/1 - I also want that all existing files and directories under the root directory are accessible, except Kohana’s system directories
system,application, andmodules. Any attempt to access system files and directories(beginning with dots, like .htaccess or .settings) should be disallowed also.
All clear. So let’s do it!
Read more »


