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

I have read several thread to avoid this message:
“The current PHP memory limit is below the recommended value of 512MB.”

I change in /etc/php/php.ini

image
may be it 's not the right php.ini.
could tell me where I can put 512M in which file to avoid this message.
thanks

I have the same issue.
I have modified php.ini both in apache2 and cli, but same error.

php -v
PHP 8.0.3 (cli) (built: Mar 5 2021 07:54:13) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.3, Copyright (c) Zend Technologies
with Zend OPcache v8.0.3, Copyright (c), by Zend Technologies

sudo -u www-data php -i | grep memory_limit
memory_limit => 1024M => 1024M

sudo -u www-data php -i
phpinfo()
PHP Version => 8.0.3

System => Linux delucloud 5.4.0-72-generic #80-Ubuntu SMP Mon Apr 12 17:35:00 UTC 2021 x86_64
Build Date => Mar 5 2021 07:54:13
Build System => Linux
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /etc/php/8.0/cli
Loaded Configuration File => /etc/php/8.0/cli/php.ini

Thank you
Andrea

Is there someone here?

I have also encountered this problem

sed -ri '/memory_limit/s/[0-9]+/512/' `find / -name php.ini`

Restart php-fpm after modification

I executed this line:
sed -ri ‘/memory_limit/s/[0-9]+/512/’ find / -name php.ini

Error is gone
BUT!
When I start the updater in putty I get THIS:

PLS. HELP to solve this
THX

The sed command you posted simply replaces any numeric value, following the expression memory_limit, in any php.ini file on your system, to a value of 512. So far, so good…

My guess is that you are using PHP-FPM and therefore there are two php.ini files on your system. One is in /etc/php/version.number/cli/ and the other one in /etc/php/version.number/fpm/

In one of those files, probably the one in /etc/php/.../cli/, the value was perviously set to -1 (for unlimited) which then was changed to an invalid value of -512 by the sed command.

I would recommand to manually edit this file, using a text editor of your choice and then either set the value back to -1 or to 512M.

THX
edited both files there was:
memory_limit = 512M
Changed to
memory_limit = -1
reboot
Wanted to add missing indices, but still this:

root@nextcloud ~# sudo -u www-data php /var/nextcloud/occ db:add-missing-indices
PHP Warning:  Invalid "memory_limit" setting. Invalid quantity "-512": value is                                           out of range, using overflow result for backwards compatibility in Unknown on li                                          ne 0
PHP Warning:  Failed to set memory limit to 512 bytes (Current memory usage is 2                                          097152 bytes) in Unknown on line 0
Could not open input file: /var/nextcloud/occ
root@nextcloud ~#

Is there still another config file in use??

In system at PHP, I have:
Version: 7.4.33
Memory limit: -1 B
Max execution time: 3600
Upload max size: 2 MB

The error message says:

[quote="Witzker, post:8, topic:113143"]
`Invalid "memory_limit" setting. Invalid quantity "-512": value is out of range

Maybe the value -512 is set somewhere else: user.ini, .htaccess? Or maybe you have multiple PHP versions installed and edited the files of the wrong version…? Also make sure that the memory_limit line is only included once in each file. Other than that, I’m not sure what else could cause this error.

Btw. It’s not good practice to use -1, I use 2048M, which is probably still overkill. I would recommend using 512M on a server with 2GB of RAM or less, 1024M on servers with 4GB of RAM, 2048M on a server with 8GB of RAM.

EDIT:
Not sure if this is related to your issue, but you probably also want to increase the upload_max_filesize and post_max_size. https://docs.nextcloud.com/server/latest/admin_manual/configuration_files/big_file_upload_configuration.html

in der user.ini , .htaccess ? steht nix

Ja, wie soll ich die Datei finden?
Wo schreibt der Befehl das denn hin?

You had -1 as a memory setting. Now with your sed command, you changed it to -512, as you only swapped the number after the equal sign, hence not removing the minus.

Ok !!
And is there a command that writes the right thing there (wherever it is)?

I think there is, but it is not my strong side. Try just find anywhere memory_limit=-512 is found (grep -f “memory_limit=-512” /etc/php*

I think. Then correct them one by one.

THX:
BUT
root@nextcloud ~# grep -f “memory_limit=-512” /etc/php*
grep: “memory_limit=-512”: No such file or directory
root@nextcloud ~#

hah! Sorry. Switch ordre of the parameters.

Sorry i do not understand
Pls give me the command
THX

sudo grep -Ril “memory_limit=-512” /

THX
output:
root@nextcloud ~# sudo grep -Ril “memory_limit=-512” /
grep: warning: /bin/X11: recursive directory loop
grep: /proc/sys/fs/binfmt_misc/register: Invalid argument
grep: /proc/sys/net/ipv4/route/flush: Permission denied
grep: /proc/sys/net/ipv6/conf/all/stable_secret: Input/output error
grep: /proc/sys/net/ipv6/conf/default/stable_secret: Input/output error
grep: /proc/sys/net/ipv6/conf/eth0/stable_secret: Input/output error
grep: /proc/sys/net/ipv6/conf/lo/stable_secret: Input/output error
grep: /proc/sys/net/ipv6/route/flush: Permission denied
grep: /proc/sys/vm/compact_memory: Permission denied
grep: /proc/sys/vm/drop_caches: Permission denied

What now??
PLs. help

Without some advanced output manipulation, you will see many errors.

Try this:

grep -R “memory_limit” /etc/

Not that this is advanced, but it is cut to basics, live with the errors it also outputs, and focus only on the findings yourself.

grep --include=*.ini -rnw ‘/’ -e “memory_limit”

Produces:
grep: /proc/sys/fs/binfmt_misc: Permission denied
grep: /proc/tty/driver: Permission denied
grep: /sys/kernel/tracing: Permission denied
grep: /sys/kernel/debug: Permission denied
grep: /sys/kernel/config: Permission denied
grep: /sys/fs/pstore: Permission denied
grep: /sys/fs/fuse/connections/55: Permission denied
grep: /dev/.lxd-mounts: Permission denied
/etc/php/8.1/cli/php.ini:430:memory_limit = -1
/etc/php/8.1/apache2/php.ini:430:memory_limit = 128M
/etc/php/8.1/fpm/php.ini:431:memory_limit = 5G

The last three lines is the interesting part.

On a standard Ubuntu this should be enough:
grep --include=*.ini -rnw ‘/etc/php’ -e “memory_limit”

So to narrow it down:
grep --include=*.ini -rnw ‘/etc/php’ -e “memory_limit = -512”

If the narrowed down search does not find all, then at some occasions there is custom ini files under /usr/

Then use the above command, but on / only. Be aware that it will produce many “error”, and it can be hard to find the needle in the haystack, but it will work.