Nginx / fpm and PHP_VALUE not working

nginxPHPphp-fpm

I am trying to alter some php.ini values for a single site of my web server:

fastcgi_param  PHP_VALUE  "auto_prepend_file=/var/www/profile/external/header.php \n auto_append_file=/var/www/profile/external/footer.php";

but the value is totally ignored by FPM.

I have tried to add the line either on top of the vhost configuration or under the location ~* .php$ { directive but none works

Here is my vhost configuration under nginx:

server {
  listen          80;
  index           index.php index.html;
  server_name     myvisit;
  root            /var/www/mv/head/myvisit/;
  access_log      /var/log/nginx/myvisit-access.log;
  error_log       /var/log/nginx/myvisit-error.log;

  fastcgi_param   PHP_VALUE  "auto_prepend_file=/var/www/profile/external/header.php \n auto_append_file=/var/www/profile/external/footer.php";

  # Use gzip compression
  # gzip_static       on;  # Uncomment if you compiled Nginx using --with-http_gzip_static_module
  gzip                on;
  gzip_disable        "msie6";
  gzip_vary           on;
  gzip_proxied        any;
  gzip_comp_level     5;
  gzip_buffers        16 8k;
  gzip_http_version   1.0;
  gzip_types          text/plain text/css application/json application/x-javascript text/xml application/$

  # error pages
  error_page   500 502 503 504  /50x.html;
  location = /50x.html {
    root   /var/www;
  }

  # Deny access to hidden files
  location ~* /\.ht {
    deny            all;
    access_log      off;
    log_not_found   off;
  }

  location / {
    try_files $uri $uri/ /index.php?$args;
  }

  location ~* /myvisitv3[-_](.*)\.(?:html|php) {
      try_files $uri $uri/ /myvisitv3.php?libAdresse=$1&$args;
  }

  location ~* /favicon.(?:ico|png|bmp|jpg)$ {
      try_files $uri $uri/ /web/img/favicon.ico;
  }

  # Pass PHP scripts on to PHP-FPM
  include global/php-fpm.conf;
  location ~* \.php$ {
    include /etc/nginx/fastcgi_params;
    try_files       $uri /index.php;
    fastcgi_index   index.php;
    fastcgi_pass    php5-fpm-sock;
    include         fastcgi_params;
    fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
    fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
    fastcgi_param   PHP_VALUE          "auto_prepend_file=/var/www/profile/external/header.php \n auto_append_file=/var/www/profile/external/footer.php";
  }
}

Best Answer

It does not work in all Linux distributions. For details see the comments on PHP bug #51595