0

It might seem a stupid question, but I'm already trying since one hour to figure it out without success.

As stated in title, I'm actually unable to change memory_limit directive in PHP 7.1.15 but only for php-fpm. In fact if I execute php -i | grep memory_limit in terminal I can see the correct value memory_limit => -1 => -1.

What I tried so far:

  • Setting memory_limit in php.ini
  • Using ini_set('memory_limit', -1); directly in PHP script

I also tried to disable all loaded extensions cause I thought maybe one of them is overwriting that setting, but didn't work.

Also consider that edited php.ini file is the correct one since I was able to change max_execution_time without any problem.

So how this code

ini_set('memory_limit', -1);
echo ini_get('memory_limit');
exit;

can return 128M as output?

3
  • Try setting php_admin_value[memory_limit] = -1 within your php-fpm.conf file. Commented May 30, 2018 at 10:22
  • It worked, thank you very much! You can write it as answer :) Commented May 30, 2018 at 10:41
  • Also would be nice to know in this situation how could I set memory_limit at runtime.. Commented May 30, 2018 at 11:01

2 Answers 2

4

To change the memory limit for PHP-FPM, add the following line to your php-fpm.conf file:

php_admin_value[memory_limit] = -1
Sign up to request clarification or add additional context in comments.

Comments

1

from fpm-config

;   php_value/php_flag             - you can set classic ini defines which can
;                                    be overwritten from PHP call 'ini_set'.
;   php_admin_value/php_admin_flag - these directives won't be overwritten by
;                                     PHP call 'ini_set'

You must chose better solution for you. I'm prefer set lower memory limit in global config, and in places (wo I can't rewrite better) I'm add ini_set('memory_limit', xxx);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.