After running Nginx for a while. You can read how I install LEMP server with Linux, Nginx, PHP-FPM, and MySQL on Centos. I got tons of warn logs from nginx on Centos an upstream response is buffered to a temporary file which I don’t like to see. The problem is that I didn’t set fastcgi_buffer for nginx so nginx gives out warn upstream response is buffered to a temporary file /var/cache/nginx/fastcgi_temp/.
To view Nginx’s error log
# cat /var/log/nginx/error.log
There are many an upstream response is buffered to a temporary file /var/cache/nginx/fastcgi_temp/ warn logs from forum.namhuy.net. The warning messages means response was buffered to disk. It’s not that important problem but I don’t want to get any kind of error. You can disable disk buffering with “fastcgi_max_temp_file 0″ in your .conf file or set fastcgi_buffers and fastcgi_buffer_size
2014/05/10 03:56:06 [warn] 1483#0: *144520 an upstream response is buffered to a temporary file /var/cache/nginx/fastcgi_temp/5/78/0000003785 while reading upstream, client: 54.86.133.62, server: forum.namhuy.net, request: "GET /style.php?id=1&lang=en&sid=69475f2bd936d3e96ef925ce546a79c9 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "forum.namhuy.net", referrer: "http://forum.namhuy.net/viewforum.php?f=3&sid=74d333aafeefe7332a418519e8b03277" 2014/05/10 03:56:28 [warn] 1483#0: *144518 an upstream response is buffered to a temporary file /var/cache/nginx/fastcgi_temp/6/78/0000003786 while reading upstream, client: 54.86.133.62, server: forum.namhuy.net, request: "GET /style.php?id=1&lang=en HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "forum.namhuy.net", referrer: "http://forum.namhuy.net/posting.php?mode=post&f=3&sid=69475f2bd936d3e96ef925ce546a79c9" 2014/05/10 03:57:40 [warn] 1483#0: *144673 an upstream response is buffered to a temporary file /var/cache/nginx/fastcgi_temp/7/78/0000003787 while reading upstream, client: 198.204.244.53, server: forum.namhuy.net, request: "GET /style.php?id=1&lang=en&sid=b70a193e6808fb2183ac1c0228097227 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "forum.namhuy.net", referrer: "http://forum.namhuy.net/viewforum.php?f=2&sid=74d333aafeefe7332a418519e8b03277" 2014/05/10 03:58:06 [warn] 6276#0: *37 an upstream response is buffered to a temporary file /var/cache/nginx/fastcgi_temp/1/00/0000000001 while reading upstream, client: 198.204.244.53, server: forum.namhuy.net, request: "GET /style.php?id=1&lang=en HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "forum.namhuy.net", referrer: "http://forum.namhuy.net/viewtopic.php?f=2&t=2&sid=b70a193e6808fb2183ac1c0228097227"
To disable fastcgi disk buffering
# nano /etc/nginx/conf.d/default.conf
and add this line to location ~ \.php$ { fastcgi configurations }
fastcgi_max_temp_file 0;
You should have something like this
location ~ \.php$ {
root /usr/share/nginx/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_max_temp_file 0; include fastcgi_params; }
To set fastcgi_buffer_size and fastcgi_buffer
# nano /etc/nginx/conf.d/default.conf
and add this two lines to location ~ \.php$ { fastcgi configurations }
fastcgi_buffer_size 4K; fastcgi_buffers 64 4k;
location ~ \.php$ { root /usr/share/nginx/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_max_temp_file 0; fastcgi_buffer_size 4K; fastcgi_buffers 64 4k; include fastcgi_params; }