With apache+php_mod it was as easy as putting:

php_value      memory_limit        128M

into application vhost.

How can I do something like this for nginx+php-fpm?


You've got a couple of options. You can either:

1) Set the fastcgi_param of PHP_VALUE to be the relevant setting in the nginx configuration: fastcgi_param PHP_VALUE "memory_limit = 128M;" As pointed out in the comments, the trailing ; is important.

2) Set it via the php_value setting in the FPM pool configuration file. Something like php_value[memory_limit] = 128M. Use php_admin_value if you don't want the setting to be overridable via ini_set.

| improve this answer | |
  • In the second case how to do that specifically for a given application/domain. – clime Apr 17 '13 at 12:49
  • Run that application against a different PHP FPM pool. – growse Apr 17 '13 at 14:09
  • doesnt work in nginx this way nginx: [emerg] invalid number of arguments in "fastcgi_param" directive in ... – Ricardo Martins Dec 10 '14 at 12:09
  • 3
    @growse, there is a missing semicolon at the end of fastcgi_param PHP_VALUE "memory_limit = 128M" else it gives an error. Thanks – Jaspal Singh Feb 17 '17 at 18:32
  • 1
    I had to use php_admin_value[memory_limit] instead of php_value[memory_limit]. The difference between both, according to the documentation, is that the first cannot be overridden by *.ini files or ini_set(). – Gwyneth Llewelyn Jan 3 at 21:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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