Confusion over apparently conflicting advice in guide/wiki/examples

talkingnews nginx-forum at
Mon Mar 3 21:11:52 UTC 2014

I'd call myself very much a beginner with NGiNX, but I've been looking
further through the documentation, particularly the page, and now I'm left with confusion!

This page says
"This guide run fine on php.ini cgi.fix_pathinfo = 1 (the default). Some
guide insist to change it to cgi.fix_pathinfo = 0 but doing that make
PHP_SELF variable broken (not equal to DOCUMENT_URI).".

But says:
Set cgi.fix_pathinfo=0 in php.ini. This causes the PHP interpreter to only
try the literal path given and to stop processing if the file is not found.

And the provided nginx/sites-available/default says
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

Which is correct?

My second question: As I understand it, you should always make parameter
changes only where they are needed, and in an overriding way - ie: one never
touches php.ini itself.
So, I am looking at this entry:

In the server stanza there is:

server {
    fastcgi_buffers 8 16k;
    fastcgi_buffer_size 32k;
    fastcgi_read_timeout 180;

and then separately it says to add to fastcgi_params the following:

    fastcgi_connect_timeout 60;
    fastcgi_send_timeout 180;
    fastcgi_read_timeout 180;
    fastcgi_buffer_size 128k;
    fastcgi_buffers 4 256k;
    fastcgi_busy_buffers_size 256k;
    fastcgi_temp_file_write_size 256k;
    fastcgi_intercept_errors off;

Some of those numbers are HUGE - most of the buffer defaults are normally
4k|8k. And 3 minutes between connections? Is this over-the-top? And the
three items in server are conflicted by different values in fastcgi params.

And isn't that going to "pollute" the whole fpm server? I thought it would
be better to have it in the fpm pool, so first I had it like this:

php_value[upload_max_filesize] = 128M
php_value[max_file_uploads] = 60
php_value[default_socket_timeout] = 180
php_value[date.timezone] = 'Europe/London'
php_value[session.gc_maxlifetime] = 28800

The I realised I only needed these high values for one area of my server, so
again I changed it:

    location ~ /upload/ {
        location ~ \.(php)$ {
            try_files $uri =404;
            set $php_value "post_max_size = 128M";
            set $php_value "$php_value \n upload_max_filesize = 128M";
            set $php_value "$php_value \n session.gc_maxlifetime = 28800";
            set $php_value "$php_value \n max_file_uploads = 60";
            fastcgi_pass   unix:/var/run/php5-fpm.sock;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME
            fastcgi_param  PHP_VALUE $php_value;
            include fastcgi_params;

And it works fine. No core ini files are touched, only the area which need
to change is changed.

Also, the example config has:

 location ~ \.php {
                fastcgi_pass   unix:/tmp/domain.sock;
                fastcgi_split_path_info ^(.+\.php)(.*)$;
                fastcgi_param  SCRIPT_FILENAME 
                include        fastcgi_params;

But the Pitfalls guide suggests this is dangerous.

So, my question would be:

Is this example file wrong/outdated/dangerous?

Or am I completely misunderstanding something?

Posted at Nginx Forum:,248051,248051#msg-248051

More information about the nginx mailing list