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

For some reason our website has one .jsphp file that needs to be handed to the PHP-FPM.

However, access will be denied because by default PHP-FPM only allows an extension of .php.

This can be solved by adding the following to php-fpm.conf

security.limit_extensions = .php .jsphp

But I only want to do this for a particular server location in the Nginx configuration, which is shown below

location ~ (\.php|\.jsphp)$ {
    try_files $uri = 404;
    include /usr/local/etc/nginx/fastcgi_params;
    fastcgi_pass; # 9000 for xdebug
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PHP_VALUE "error_log=/usr/local/var/log/our-website.local-error.log";

Is it possible to add the PHP-FPM setting security.limit_extensions per server location? And if so, how do I do it?


share|improve this question
up vote 2 down vote accepted

I don't think it's possible to do exactly what you're asking for. The PHP-FPM config file doesn't support dynamic variables in it - everything is configured once to a set value and then the PHP-FPM pool is created with those values set.

However there are a couple of ways of solving your problem.

  1. Create a new PHP-FPM pool and have it listen on a different socket.

    i.e. copy your existing pool in your php-fpm.conf file, change the socket that it's listening on to 9002 and change the value of security.limit_extensions for just that pool. Then in your nginx config have files that have a .jsphp extension be sent to that new pool.

  2. Rename the file to be .js.php which is (imho) a better way of chaining extension types as it allows code editors to know that it is a PHP file without having to setup custom extensions in everyones editor.
    It then has a standard php extension and you don't need to worry about separate config for it.

share|improve this answer
Thanks for the suggestions. I will talk to whoever created the .jsphp file. – hobbes3 May 5 '13 at 6:40
2 years later .. So this is it "php-fpm config file doesn't support dynamic variables in it". Too bad :( I would like to keep only one pool of workers. Is there any way to dynamically chroot php-fpm based on the vhost that has been hit by the request ? I mean setting let's say a chrootvar variable inside nginx server blocks holding the chroot path to set and passing it to php-fpm ? – Stphane Oct 18 '15 at 22:31

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.