Reputation: 679
fyi this question is duplicate and many people ask to but i have collect all answer into my question what i did still on problem or doesnt work but i explain more detail and i want to know why. similar on
the case is i have 3 server ( engine ) where run an application ( laravel web ).
A. my engine ( work/no error ): ( apache Ubuntu 18.04.6 LTS )
❯ free -m
total used free shared buff/cache available
Mem: 7976 865 497 18 6613 6797
Swap: 0 0 0
B. my engine ( doesnt work/error allocate memory ): ( nginx ) ( Ubuntu 18.04.4 LTS )
➜ ~ free -m
total used free shared buff/cache available
Mem: 7975 658 4312 22 3005 7006
Swap: 4095 1 4094
C. my engine ( doesnt work/error allocate memory ): ( nginx ) ( Ubuntu 20.04.1 LTS )
~ » free -m ~
total used free shared buff/cache available
Mem: 1987 1096 112 131 778 568
Swap: 0 0 0
what i do is run a query thats export a excel file where the data is from application is build until now , so need a big memory, time or processing. if see on yesterday there is have 9000 data/row.
what i was do ( with my three server )
my server (B) on doesnt work is here : (my configuration)
➜ ~ locate php.ini
/etc/php/7.4/apache2/php.ini
/etc/php/7.4/cli/php.ini
/etc/php/7.4/fpm/php.ini
/usr/lib/php/7.4/php.ini-development
/usr/lib/php/7.4/php.ini-production
/usr/lib/php/7.4/php.ini-production.cli
/usr/lib/php/8.1/php.ini-development
/usr/lib/php/8.1/php.ini-production
/usr/lib/php/8.1/php.ini-production.cli
➜ ~ php -i | grep php.ini
Configuration File (php.ini) Path => /etc/php/7.4/cli
Loaded Configuration File => /etc/php/7.4/cli/php.ini
then i modified the php memory
// [ 1 ]
// /etc/php/7.4/cli/php.ini
max_execution_time = 3600
max_input_time = -1
memory_limit=512M // i have tried set to 2048M or -1 or 99999999999M
then i restart the php and nginx for measure ...
➜ ~ sudo service nginx restart && sudo service php7.4-fpm restart
➜ ~ nginx -s reload
nothing error but still on problem allocate memory stuck on 16384 bytes
so i tried override the setting on index.php
its on laravel/index.php and laravel/public/index.php
i put these code and paste into .php file.
<?php
set_time_limit(0);
ini_set('memory_limit', '-1');
ini_set('max_execution_time', 360);
still on problem . what i was debug is when i tried to set the memory only 512M its alert is guide me to increase more memory ( Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) ) but when i tried increase into 2048M the alerts is a different ( Allowed memory size of 268435456 bytes exhausted (tried to allocate 16384 bytes)
so we can close understand here for first
can anyone explain why ? stuck on 16384 bytes ... what ever i increase to the maximum.
but on my first server with apache its work on configuration and tricky of override instead of index.php apache is use .htaccess.
Upvotes: 1
Views: 3921
Reputation: 179
You edited /etc/php/7.4/cli/php.ini
as I did understand it. This is only the config file for your php cli.
Nginx is using /etc/php/7.4/fpm/php.ini
You need to alter your memory limit there
Upvotes: 1