« Glue vs. Full-Stack: The Podcast Edition
» New CakePHP Podcast Launched

CakePHP, Chris' Brain

Configuring CakePHP to Work With Nginx

09.14.07 | 5 Comments

I use the incredibly small high-performance web server Nginx to run this blog and some of my other projects. Again, the ADD developer in me likes trying out new technology and nginx is a great fit for me so far. I had to dig around a bit to find some rewrite rules that work for using WordPress (I’ll share those if people are interested) but I got an email this morning from a fellow CakePHP user who couldn’t find any configuration info on how to get it to work with Nginx. Well, I did some fooling around and I’m confident this set of rules will work. This assumes that you’ve gotten Nginx already up and running.

# CakePHP rewrite rules
location / {
     index index.php;
     if (!-e $request_filename) {
          rewrite ^/(.+)$ /webroot/$1 last;
          break;
     }
}

location /webroot/ {
     index index.php;
     if (!-e $request_filename) {
          rewrite ^(.+)$ index.php?url=$1 last;
          break;
     }
}

I am by no means an nginx expert, so if you have problems you are probably on your own. I hope this helps out other people wanting to run CakePHP on nginx.

5 Comments

have your say

Add your comment below, or trackback from your own site. Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

:

:


« Glue vs. Full-Stack: The Podcast Edition
» New CakePHP Podcast Launched