The current PHP memory limit is below the recommended value of 512MB?

NC14.0.3 + Debian 9 + PHP 7.2:

After every occ command comes:

The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http://php.net/manual/en/book.pcntl.php
The current PHP memory limit is below the recommended value of 512MB.

But i have definitely 513 MB memory_limit.

How can i let the error message disappear?

1 Like

You are sure about the limit?

php -i | grep memory_limit

It can and it is in general different if you call php from command line or via browser. What is a bit difficult is that the value can be changed at different locations. Therefore, the most reliable test is to put a small script which shows you the limit.

sudo -u www-data php72 -i | grep memory_limit
memory_limit => 128M => 128M

But phpinfo.php is showing me 513 MB

You have two php.ini files in your system:

  • /etc/php/7.2/cli/php.ini (for php CLI)
  • /etc/php/7.2/apache2/php.ini (used by the webserver)

When you do a GET /phpinfo.php you’re calling the webserver, when you run php72 -i | grep memory_limit the other config file is used.

I believe that occ commands use the CLI ini file.

4 Likes

Hi guys, the easiest way to fix the message is the following:

sudo gedit /etc/php/7.2/apache2/php.ini

then look for:

[memory_limit] = 512M

After chaging to 512M restart apache

sudo systemctl restart apache2.service

2 Likes

I’ve done that but I still get the message, even after a full server reboot

Same here. Also modified the entry in fpm/php.ini, message still remains. Maybe it’s related to the -1 entry for cli? (I assume that’s “unlimited”?) Or maybe because it’s “memory_limit” without brackets in PHP7.3’s php.ini?

same problem (v16.0.3.0)
in
/etc/php/7.3/cli/php.ini
I set
memory_limit = 1000M
then
sudo -u www-data php7.3 -i | grep memory_limit
yields
memory_limit => 1000M => 1000M
but the error after reboot is still there

Normally, in this output it should also tell you which configuation file is used:

sudo -u www-data php7.3 -i

I’m wondering if php also takes other files in the folder into accound (like .htaccess or user.ini)…

Actually plenty, it seems: https://pastebin.com/uJ0icJqX

This is the main one:
/etc/php/7.3/cli/php.ini

The others are included from there.

There is a third php.ini in play. If you’re using php-fpm, wich is likely, chances are your system is using /etc/php/7.3/fpm/php.ini. And that’s where you go to fix it. Restart php-fpm, and you’re done.

The 7.3 may be 7.2 or different, depending on what you use, of course. A phpinfo.php file will tell you exactly what the webserver is using.
Creating a phpinfo.php file is easy: create a text file, and put:

<?php
phpinfo();
?>

in it. Save as phpinfo.php and put it on your webserver. Call it from your browser and check output.

Good luck!

2 Likes

I’m not really a good programmer but when one of you from a comment said " sudo systemctl restart apache2.service". i thougt, instead of editing the ( in my case ) /etc/php/7.3/cli/php.ini file, i could try the /etc/php/7.3/apache2/php.ini file. After editing the memory limit from
memory_limit = 128MB
to
memory_limit = 512MB
it worked. I don’t have that “error” anymore.
note that I have changed them both to the same number. I don’t know if that is a important thing to do but I did it anyway.

2 Likes

Hi guys,

Did all the steps above, but I still have the error. Edited both /etc/php/7.3/cli/php.ini and etc/php/7.3/apache2/php.ini, restarted apache server (even rebooted the machine), but issue still persist.
Any idea?

Ubuntu 20.04 LTS
Nextcloud v.20.01
Php 7.4 (no fpm is installed)

Output of querying the memory_limit:
php -i | grep memory_limit
memory_limit => 512M => 512M

sudo -u www-data php7.4 -i | grep memory_limit
memory_limit => 512M => 512M

Then use the method with the phpinfo() from lturbide. Then you see the location of your php.ini file used. checkout as well the apache config files and .htaccess since you can change the parameters there as well.

Hello,

I am having the same issue.

i modified
/etc/php/7.4/apache2/php.ini
/etc/php/7.4/cli/php.ini
/etc/php/7.4/fpm/php.ini

memory_limit => 512M => 512M
grep memory_limit /etc/php/7.4/apache2/php.ini  /etc/php/7.4/cli/php.ini  /etc/php/7.4/fpm/php.ini
/etc/php/7.4/apache2/php.ini:memory_limit = 512MB
/etc/php/7.4/cli/php.ini:memory_limit = 512M
/etc/php/7.4/fpm/php.ini:memory_limit = 512M

I checkled the phpinfo.php as instructed, I find 512M there also
I check the php.ini file location :

Configuration File (php.ini) Path 	/etc/php/7.4/apache2
Loaded Configuration File 	/etc/php/7.4/apache2/php.ini
Scan this dir for additional .ini files 	/etc/php/7.4/apache2/conf.d 

Any help ??