Exception or error:
What is a good way of using PHP with nginx? From the finding I got, maybe using PHP-FPM might be a good way of handing PHP behind nginx.
The problem we have is that the free web based API we serve gets a lot of request (about 500K a day), the requests are mostly very short and small in size but Apache is consuming a lot of memory. I want to try nginx to see if it can handle it better.
Thanks.
How to solve:
- Ubuntu Lucid 64-bit
- apt-get install nginx
- apt-get update
- apt-get install php5-cli php5-common php5-suhosin
- apt-get install python-software-properties
- add-apt-repository ppa:brianmercer/php
- apt-get update && apt-get install php5-fpm php5-cgi
- /etc/init.d/nginx restart
- /etc/init.d/php5-fpm restart
Edit (might need this in your site conf) :
location ~ \.php$ {
fastcgi_read_timeout 60000;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/site$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}