Magento 2

Magento 2 installation: PHP Fatal error Allowed memory size exhausted

A frequent problem during Magento 2 installation (using php bin/magento setup:install ) is a site running out of memory and generating an error like this – “PHP Fatal error: Allowed memory size of NNN bytes exhausted”. This fatal error means that your hosting or local machine is not able to provide enough memory for the installation script to run correctly.
 
Allowed memory size exhausted
 
There are full error and php stack trace:
 
$ php bin/magento setup:install --admin-firstname name \
 --admin-lastname lastname --admin-email=email@email.com
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 5 bytes)
 in magento2/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php
on line 228
 
PHP Stack trace:
By default magento 2 limits its memory usage to 256Mb in the main magento2/pub/.htaccess file:
 
magento2/pub/.htaccess
############################################
## adjust memory limit
 
    php_value memory_limit 256M
    php_value max_execution_time 18000
So it’s better to have at least 256M in your php configuration.
 
Solution:
 
1) change php.ini to encrease memory_limit value on global level
To find the php.ini file use “php –ini” command from your console
 
php.ini
 
...
; How many GET/POST/COOKIE input variables may be accepted
; max_input_vars = 1000
 
; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 256M
...
2) Also you can change the memory limit locally just for the magento2 shell script file:
add ini_set(“memory_limit”,”256M”) to the “magento2/bin/magento” file
 
magento2/bin/magento
 
#!/usr/bin/env php
<?php
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
ini_set('memory_limit', '256M');
use Magento\Framework\AppInterface;
if (PHP_SAPI !== 'cli') {
    echo 'bin/magento must be run as a CLI application';
    exit(1);
}
3) Also you can change the memory limit just for the php run
 
 
php -dmemory_limit=1G bin/magento setup:install
Check current memory_limit value:
 
1) Run command:
 
php -r "echo ini_get('memory_limit').PHP_EOL;"
2) Run command:
 
php -i | grep memory
This will output something like the following:
 
 
$ php -i | grep memory
memory_limit => 128M => 128M
Collecting memory statistics => Yes
3) Create php script phpinfo.php and add next code:
 
 
<?php phpinfo(); ?>
 

2 Bình luận

  1. advance nói:

    Men at risk for a heart attack need to speak with the doctor before using cash advance in Pennsylvania Philly.

  2. Nguyễn Hữu Cầu nói:

    Bài hướng dẫn Magento này rất hay ạ! Cám ơn bạn rất nhiều!

Trở về
  • Magento plug-ins
  • Magento plug-ins

    Magento2 gave very good concept called Plugin   we can do what ever after and before core function and also we have...

  • HOW TO CREATE MENU IN MAGENTO 2 ADMIN
  • HOW TO CREATE MENU IN MAGENTO 2 ADMIN

    magento-2-admin- menu My previous tutorial show you how to create a simple module in Magento 2, learn more here: http://www.venustheme.com/how-to-create-magento-2-module/....