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.
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 1. {main}() magento2/bin/magento:0
PHP 2. Symfony\Component\Console\Application->run() magento2/bin/magento:25
PHP 3. Magento\Framework\Console\Cli->doRun() magento2/vendor/symfony/console/Symfony/Component/Console/Application.php:126
PHP 4. Symfony\Component\Console\Application->doRun() magento2/vendor/magento/framework/Console/Cli.php:49
PHP 5. Symfony\Component\Console\Application->doRunCommand() magento2/vendor/symfony/console/Symfony/Component/Console/Application.php:195
PHP 6. Symfony\Component\Console\Command\Command->run() magento2/vendor/symfony/console/Symfony/Component/Console/Application.php:874
PHP 7. Magento\Setup\Console\Command\InstallCommand->execute() magento2/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:257
PHP 8. Magento\Setup\Model\Installer->install() magento2/setup/src/Magento/Setup/Console/Command/InstallCommand.php:125
PHP 9. call_user_func_array:{magento2/setup/src/Magento/Setup/Model/Installer.php:331}() magento2/setup/src/Magento/Setup/Model/Installer.php:331
PHP 10. Magento\Setup\Model\Installer->installDataFixtures() magento2/setup/src/Magento/Setup/Model/Installer.php:331
PHP 11. Magento\Setup\Model\Installer->handleDBSchemaData() magento2/setup/src/Magento/Setup/Model/Installer.php:746
PHP 12. Magento\ConfigurableSampleData\Setup\InstallData->install() magento2/setup/src/Magento/Setup/Model/Installer.php:798
PHP 13. Magento\Framework\Setup\SampleData\Executor->exec() magento2/vendor/magento/module-configurable-sample-data/Setup/InstallData.php:33
PHP 14. Magento\Framework\App\State->emulateAreaCode() magento2/vendor/magento/framework/Setup/SampleData/Executor.php:50
PHP 15. call_user_func_array:{magento2/vendor/magento/framework/App/State.php:171}() magento2/vendor/magento/framework/App/State.php:171
PHP 16. Magento\ConfigurableSampleData\Setup\Installer->install() magento2/vendor/magento/framework/App/State.php:171
PHP 17. Magento\ConfigurableSampleData\Model\Product->install() magento2/vendor/magento/module-configurable-sample-data/Setup/Installer.php:57
PHP 18. Magento\ImportExport\Model\Import\Interceptor->importSource() magento2/vendor/magento/module-configurable-sample-data/Model/Product.php:96
PHP 19. Magento\ImportExport\Model\Import\Interceptor->___callPlugins() magento2/var/generation/Magento/ImportExport/Model/Import/Interceptor.php:104
PHP 20. call_user_func_array:{magento2/vendor/magento/framework/Interception/Interceptor.php:144}() magento2/vendor/magento/framework/Interception/Interceptor.php:144
PHP 21. Magento\ImportExport\Model\Import->importSource() magento2/vendor/magento/framework/Interception/Interceptor.php:144
PHP 22. Magento\ImportExport\Model\Import->processImport() magento2/vendor/magento/module-import-export/Model/Import.php:413
PHP 23. Magento\ImportExport\Model\Import\Entity\AbstractEntity->importData() magento2/vendor/magento/module-import-export/Model/Import.php:448
PHP 24. Magento\CatalogImportExport\Model\Import\Product->_importData() magento2/vendor/magento/module-import-export/Model/Import/Entity/AbstractEntity.php:578
PHP 25. Magento\CatalogImportExport\Model\Import\Product->_saveProductsData() magento2/vendor/magento/module-catalog-import-export/Model/Import/Product.php:844
PHP 26. Magento\CatalogImportExport\Model\Import\Product->_saveProducts() magento2/vendor/magento/module-catalog-import-export/Model/Import/Product.php:876
PHP 27. Magento\CatalogImportExport\Model\Import\Product->_saveProductAttributes() magento2/vendor/magento/module-catalog-import-export/Model/Import/Product.php:1613
PHP 28. Magento\Framework\DB\Adapter\Pdo\Mysql->insertOnDuplicate() magento2/vendor/magento/module-catalog-import-export/Model/Import/Product.php:1160
PHP 29. Magento\Framework\DB\Adapter\Pdo\Mysql->query() magento2/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php:1842
PHP 30. Magento\Framework\DB\Adapter\Pdo\Mysql->_query() magento2/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php:499
PHP 31. Zend_Db_Adapter_Pdo_Abstract->query() magento2/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php:444
PHP 32. Zend_Db_Adapter_Abstract->query() magento2/vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php:238
PHP 33. Zend_Db_Statement->execute() magento2/vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php:480
PHP 34. Magento\Framework\DB\Statement\Pdo\Mysql->_execute() magento2/vendor/magento/zendframework1/library/Zend/Db/Statement.php:303
PHP 35. Zend_Db_Statement_Pdo->_execute() magento2/vendor/magento/framework/DB/Statement/Pdo/Mysql.php:95
PHP 36. PDOStatement->execute() magento2/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php:228
By default magento 2 limits its memory usage to 256Mb in the main magento2/pub/.htaccess file:
############################################ ## 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
... ; 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
#!/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(); ?>
Pingback: PHP Fatal error Allowed memory size exhausted во время установки Magento2 - Технарь