- Fatal error: Allowed memory size of 123456 bytes exhausted (tried to allocate 234567 bytes) in /path/file.php
Usually your php.ini will be located at (XX – PHP version, for example 73):
vi /usr/local/php73/lib/php.ini
or use below trick to find your php.ini would be to ask php itself what it’s using, eg:
/usr/local/bin/php --ini | grep 'Loaded Configuration File'
or another trick to find php.ini
php -i | grep "php.ini"
Now open the php.ini file and edit memory_limit to a higher value.
memory_limit = 8M ; Maximum amount of memory a script may consume (8MB)
Save, and then restart apache.
systemctl start httpd.service
CentOS/RHEL (Red Hat) Linux version 7.x or newer specific commands
or
sudo systemctl restart httpd.service
Alternative way: php.ini per folder
Location of the global server php.ini file is
/usr/local/php/php.ini
Location of the global per account php.ini file is
/home/USERNAME/php.ini
You can also have per folder changes, example:
/home/USERNAME/public_html/website1.com/php.ini /home/USERNAME/public_html/website2.com/php.ini /home/USERNAME/public_html/website2.com/myapp/php.ini
How to test php.ini changes?
Simple create phpinfo.php file in the users public_html folder and add the following content in it.
Example location: /home/USERNAME/public_html/phpinfo.php
<?php
phpinfo();
?>
Now open url in your browser (Apache restart is NOT needed):
http://your-domain.com/phpinfo.php
PHP.ini values
http://php.net/manual/en/ini.list.php