3 ms·
It really is trivial to set up an fcgi process to run PHP directly from nginx. On the nginx side, something like my config: location ~ \.php {
by justincormack 16y ago
It really is trivial to set up an fcgi process to run PHP directly from nginx.
On the nginx side, something like my config:
location ~ \.php {
fastcgi_index index.php;
include fastcgi_params;
fastcgi_pass localhost:55155;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
Then you just need to run php in fcgi daemon mode which is built in, use php-cgi -b localhost:55155 to match that setup... more details on http://wiki.nginx.org/PHPFcgiExample http://wiki.nginx.org/PHPFcgiExample
I found this much simpler than running nginx and apache...
- chopsueyar 16y agoA socket is probably faster.
- justincormack 16y agoNot really the bottleneck if you are running PHP. Linux optimises most of tcp out over the loopback device anyway.
- treo 16y agoI ran into a problem with a tcp connection to php-fpm just some weeks ago: The Server served requests at a rate of about 400req/s for some time without a single problem, until I ran out of useable ports. You won't have this problem with sockets.
- nbpoole 16y agoIf you do that, you have to be very careful. I actually did a writeup about this a few days ago that I posted on HN: https://nealpoole.com/blog/2011/04/setting-up-php-fastcgi-and-nginx-dont-trust-the-tutorials-check-your-configuration/ https://nealpoole.com/blog/2011/04/setting-up-php-fastcgi-an... tl:dr is that the configuration you're suggesting will leave a site open to arbitrary code execution if the site allows for user uploads.
- justincormack 16y agoThats not a full config, I did reference the documentation. I have a try_files line, as fcgi runs locally as it happens.
- Yaa101 16y agoJust use PHP-FPM instead, it's easier and scales better. I run PHP, Django/Python and Perl without a problem at a single domain. NGINX allows to run almost anything as long as you are able to attach the socket of what you want to output towards NGINX.