Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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";
share|improve this question

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

share|improve this answer
awwww ! is there a workaround to make it works only for a given vhost ? – kitensei May 16 '13 at 8:23
If you have a separate FPM pool for each vhost (and you should for security), you can just put the config into the vhost's FPM pool. – Janoszen May 16 '13 at 8:32
ok i'll check how to do that :) – kitensei May 16 '13 at 8:33
Based on that bug, it may be an escaping issue for some reason. – Kzqai Nov 14 '14 at 3:42

It works for me, but only in location context. In server context it works different as one could expect. Discussed on nginx forum: fastcgi_param in server context does not work.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.