# PHP memory limit: Cannot be changed

**URL:** <https://community.nginx.org/t/php-memory-limit-cannot-be-changed/7228>\
**Category:** NGINX\
**Tags:** php-fpm, web-server\
**Created:** [October 1, 2025, 11:57am UTC](https://community.nginx.org/t/php-memory-limit-cannot-be-changed/7228 "2025-10-01T11:57:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jenne](https://drob5swvtjqxg.cloudfront.net/user_avatar/community.nginx.org/jenne/32/2439_2.png) [@Jenne](https://community.nginx.org/u/Jenne)\
**Post date:** [October 1, 2025, 11:57am UTC](https://community.nginx.org/t/php-memory-limit-cannot-be-changed/7228/1 "2025-10-01T11:57:50Z")

</div>

And again another question, now dealing with the PHP memory\_limit…

When using Apache based servers I hat to change the PHP memory\_limit values several times within the php.ini file. While optimizing my WordPress installation within my NGinx server surroundings I noticed that the PHP memory limit is set to 128 MB - which _could_ be not sufficient for some other web applications I intend to install and use.

Following several guides I changed the PHP version used by NGinx and WordPress from 8.2 to version 8.4, deleting the older versions with success. I made sure PHP-FPM is installed and running.

Whenever opening the php.ini file I noticed following directive:

”memory\_limit: -1”

No matter to what amount I changed it (always using 128M, 512M or alike) PHP info got stuck on 128M (and yes, I always restarted PHP and NGinx after changing the php.ini file). WordPress suggests installation of page cache plugins (which works ok to some degree) but I am not a dedicated fan of those plugins. Nevertheless other web based apps demand a minimum of 512M or even more.

I did an intense search but I still did not find any documentation that explains that “-1” value. I triple-checked that my NGinx installation makes use of PHP 8.4 (fastcgi\_pass unix:/run/php/php8.4-fpm.sock;) and whenever checking the PHP settings I was sure to edit the right php.ini. - so what am I missing here? Any hint on this?

Thanks in advance again very much!

Jens

---

<div class="post-metadata">

**Author:** ![alessandro](https://drob5swvtjqxg.cloudfront.net/user_avatar/community.nginx.org/alessandro/32/4836_2.png) [@alessandro](https://community.nginx.org/u/alessandro)\
**Post date:** [October 1, 2025, 2:38pm UTC](https://community.nginx.org/t/php-memory-limit-cannot-be-changed/7228/2 "2025-10-01T14:38:01Z")

</div>

Hi @Jenne!

I am not a PHP expert myself, but a cursory Google search seems to indicate `memory_limit: -1` fundamentally means that PHP will not have an actual memory limit and thus can use as much memory as necessary/possible (see [PHP: Description of core php.ini directives - Manual](https://www.php.net/manual/en/ini.core.php#ini.memory-limit) for more info).

Digging a bit more into your issue, it seems as if it might be related to conflicts between different `php.ini` files being present in your system. Hopefully this Reddit thread ([https://www.reddit.com/r/PHPhelp/comments/11ttxje/php\_ignoring\_memory\_limit\_change\_set\_at\_128m](https://www.reddit.com/r/PHPhelp/comments/11ttxje/php_ignoring_memory_limit_change_set_at_128m)) will prove helpful in figuring it out!

---

<div class="post-metadata">

**Author:** ![Jenne](https://drob5swvtjqxg.cloudfront.net/user_avatar/community.nginx.org/jenne/32/2439_2.png) [@Jenne](https://community.nginx.org/u/Jenne)\
**Post date:** [October 2, 2025, 6:20am UTC](https://community.nginx.org/t/php-memory-limit-cannot-be-changed/7228/3 "2025-10-02T06:20:20Z")

</div>

Again thanks a lot, Alessandro!

While reading Your provided second link the solution was more or less obvious to some degree. The good old way to make a PHP info file led me to the actual ini used by my PHP 8.4 installation (different location as expected). Now everything is fine, memory limit raised to the desired amount.

Digging deeper into that “-1” thing I guess that this is some sort of “alias” or “sym link” function within PHP pointing to the ini file that actually defines the amount of memory. Not completely sure about this but as all ini files of PHP version 8.1, 8.2 and 8.3 formerly installed in my system make use of that “-1” definition I am coming to that conclusion. In fact the ini file used is NOT located in for example /etc/php/8.4/php.ini but in /etc/php/8.4/fpm/php.ini.

In the end it doesn’t matter what and how many versions of PHP are installed as long as the right ini file within the fpm of the actually used PHP version is edited.

Again thank You very much for giving a helping hand again! I am still learning a lot about NGinx, doing all this in my spare time. Every day new things to do come to my mind when working on my little server box. I should start using a mind mapping app, I guess….

Jens

---

<div class="post-metadata">

**Author:** ![system](https://drob5swvtjqxg.cloudfront.net/user_avatar/community.nginx.org/system/32/19_2.png) [@system](https://community.nginx.org/u/system)\
**Post date:** [October 9, 2025, 6:21am UTC](https://community.nginx.org/t/php-memory-limit-cannot-be-changed/7228/4 "2025-10-09T06:21:10Z")

</div>

Closed on October 9, 2025, 6:21am UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
