Exactly what is a great way of using PHP with nginx? In the finding I acquired, maybe using PHP-FPM may well be a great way of handing PHP behind nginx.

The issue we now have would be that the free internet based API we serve will get lots of request (about 500K each day), mostly the demands are extremely short and small in dimensions but Apache is consuming lots of memory. I wish to try nginx to ascertain if it may handle it better.


  1. Ubuntu Lucid 64-bit
  2. apt-get install nginx
  3. apt-get update
  4. apt-get install php5-cli php5-common php5-suhosin
  5. apt-get install python-software-qualities
  6. add-apt-repository ppa:brianmercer/php
  7. apt-get update &lifier&lifier apt-get install php5-fpm php5-cgi
  8. /etc/init.d/nginx restart
  9. /etc/init.d/php5-fpm restart

Edit (may need this inside your site conf) :

    location ~ \.php$ {
        fastcgi_read_timeout 60000;
        fastcgi_index   index.php;
        fastcgi_param   SCRIPT_FILENAME /var/www/site$fastcgi_script_name;
        include         fastcgi_params;
    location ~ /\.ht {
            deny  all;

This is actually the link where one can setup nginx + php-fpm + apc http://interfacelab.com/nginx-php-fpm-apc-awesome/

For me, use php + lighttpd to deal with that request. Lighttpd may be the the very best webserver to deal with many request with only need small memory. After then point your nginx proxy to where lighttpd listen.

I have released a clean howto for setting up Nginx within the latest version on the Debian 6. "Squeeze" box at http://www.asconix.com/howtos/debian/nginx-php-postgresql-debian-howto

I really hope it will help large amount of people to obtain a clean setup. Any corrections and recommendations are welcome -)

Cheerio, Chris