Challenge: PHP memory limit

After my installation, the warning “The PHP memory limit is below the recommended value of 512MB” appears on the “Administration> Overview” page.

However, I have already adjusted the value to 1GB in php.ini

And already checked with this command which version is used:

php -i |grep php.ini

→ Configuration File (php.ini) Path => /etc/php/8.0/cli

Loaded Configuration File => /etc/php/8.0/cli/php.ini

It was installed under Ubuntu with a LAMP stack on a cloud at Hetzner.

Does anyone here have an idea what else it could be?

Hey,
Running php from the commandline has a different php.ini than the one used by the webserver, notice the „cli“ part in the path. Have a look at /etc/php/8.0/fpm/ for example, if you’re using fpm.

2 Likes

Thanks for your fast reply!

root@…:~# cd /etc/php/8.0/
root@…:/etc/php/8.0# ls

apache2 cli mods-available

Doesn’t look like I’m using fpm. What is that anyway?

There are different ways on how PHP is processed at your server, one way is to have it run as an apache 2 module (mod_php), another (usually faster) way is to have it run as a separate process (php-fpm). Depending on what you’re using, you have different locations for the currently used php.ini.

That being said, it looks like you’re using mod_php, so I imagine the right php.ini should be at /etc/php/8.0/apache2/php.ini.

2 Likes

That’s true! I’m using mod_php and moreover I have already checked /etc/php/8.0/apache2/php.ini and limit_memory = 1G is set there as well.

I think it should work, but I still get this error message and I’m getting desperate.

Did you reload/restart apache so the new configuration value is acutally applied?

Yes, I have done that.

Can you check if PHP 8 is really used?
https://<url>/settings/admin/serverinfo

Was Nextcloud manually installed or did you use snap or something?
Is there another memory_limit entry somewhere in that or another file which overwrites your entry?
Any typo in the php.ini?
Run grep -R "memory_limit" /etc/php/8.0/* to see if there are any other memory_limit defined.

Other than that, I don’t have an idea right now.

root@...:/etc/php/8.0/apache2# grep -R "memory_limit" /etc/php/8.0/*
/etc/php/8.0/apache2/php.ini:**memory_limit** = 1G
/etc/php/8.0/cli/php.ini:**memory_limit** = 1G
root@...:/etc/php/8.0/apache2#

I installed Ubuntu via 1click and then installed the Lamp stack via the MacOS terminal. Is that helpful?

EDIT: I’ve checked it via your URL and its version: 8.0.19
What is very strange is that the maximum size for uploading is 2 MB although I have already changed this.

Sorry the url was misformed in my inital post: https://<url>/settings/admin/serverinfo. Just go to your admin settings and to system. Have look if it actually shows PHP 8.0 (and not PHP 7.4 or something).

Just noticed you already opened a thread about this: Fehler: Die PHP-Speichergrenze liegt unterhalb des empfohlenen Wertes von 512MB
Please keep it in one thread, it just makes it harder for every one to help you.

I’ve checked it via your URL and its version: 8.0.19
What is very strange is that the maximum size for uploading is 2 MB although I have already changed this.

Yes, I tried it in my mother tongue first but didn’t get much feedback and noticed that there is not much going on in the sub forum.

Is it possible, that you can change those values in your hetzner account?
https://docs.hetzner.com/de/konsoleh/account-management/configuration/php-configuration/#php-einstellungen

There is a console in the Hetzner account that you can use as an alternative to your own terminal but I don’t think that changes anything?

Not sure, I’m not familiar with Hetzner.
Another way would be to set your values in a .htaccess file.

That’s an excellent point, I’ve read about that before. But I can’t find the file - can you help me with it?

There most likely is already one in the nextcloud directory (it’s hidden, use ls -ahl for example).

But still, if the php.ini files are the correct ones, the value gets overridden somewhere. So maybe check what’s set in the hetzner account, just to compare if the currently used values match.

root@...:/var/www/files# ls -ahl
total 176K
drwxr-xr-x 14 www-data www-data 4.0K Jun  7 20:22 .
drwxr-xr-x  5 root     root     4.0K Jun  6 15:38 ..
drwxr-xr-x 43 www-data www-data 4.0K May 19 12:09 3rdparty
drwxr-xr-x 56 www-data www-data 4.0K Jun  7 13:05 apps
-rwxr-xr-x  1 www-data www-data  19K May 19 12:04 AUTHORS
drwxr-xr-x  2 www-data www-data 4.0K Jun  7 20:23 config
-rwxr-xr-x  1 www-data www-data 3.9K May 19 12:04 console.php
-rwxr-xr-x  1 www-data www-data  34K May 19 12:04 COPYING
drwxr-xr-x 22 www-data www-data 4.0K May 19 12:09 core
-rwxr-xr-x  1 www-data www-data 6.2K May 19 12:04 cron.php
drwxr-xr-x  2 www-data www-data  12K May 19 12:04 dist
-rwxr-xr-x  1 www-data www-data 3.3K Jun  6 13:22 .htaccess
-rwxr-xr-x  1 www-data www-data  156 May 19 12:04 index.html
-rwxr-xr-x  1 www-data www-data 3.4K May 19 12:04 index.php
drwxr-xr-x  6 www-data www-data 4.0K May 19 12:04 lib
-rwxr-xr-x  1 www-data www-data  283 May 19 12:04 occ
drwxr-xr-x  2 www-data www-data 4.0K May 19 12:04 ocm-provider
drwxr-xr-x  2 www-data www-data 4.0K May 19 12:04 ocs
drwxr-xr-x  2 www-data www-data 4.0K May 19 12:04 ocs-provider
-rwxr-xr-x  1 www-data www-data 3.1K May 19 12:04 public.php
-rwxr-xr-x  1 www-data www-data 5.3K May 19 12:04 remote.php
drwxr-xr-x  4 www-data www-data 4.0K May 19 12:04 resources
-rwxr-xr-x  1 www-data www-data   26 May 19 12:04 robots.txt
-rwxr-xr-x  1 www-data www-data 2.4K May 19 12:04 status.php
drwxr-xr-x  3 www-data www-data 4.0K May 19 12:04 themes
drwxr-xr-x  2 www-data www-data 4.0K May 19 12:06 updater
-rwxr-xr-x  1 www-data www-data  101 May 19 12:04 .user.ini
-rwxr-xr-x  1 www-data www-data  382 May 19 12:09 version.php
root@...:/var/www/files# 

Thank you! I didn’t know that yet and now I have found it and learned something. What should I do now?

But the terminal in Hetzner is only an alternative to the MacOS terminal (or whichever one you use normally.) It’s not a terminal. And apart from that there is no option to change anything in php.

You need to add something like php_value memory_limit 1G to the .htaccess file

2 Likes

I just added php_value memory_limit 1G to the .htaccess file and the warning finally disappeared! Thanks a lot!!

Glad it works. Remember to also adjust the upload size.