Magento – “Command returned non-zero exit code” when trying to set M2 to production mode

magento2

When I try to bin/magento deploy:mode:set production I get the error

Command returned non-zero exit code

I already tried to

  • increase memory with -d memory_limit=2G
  • bin/magento setup:upgrade
  • clear var/cache

nothing worked.

When I do

bin/magento deploy:mode:set production --skip-compilation

bin/magento setup:di:compile

it runs successfully but the frontpage is messed up. The standard Luna theme is just a HTML output without any CSS or JS.

Here's the output of

bin/magento deploy:mode:set production -vvv 

#0 /vendor/magento/module-deploy/Model/Filesystem.php(267):
Magento\Framework\App\Shell->execute('/opt/plesk/php/…')
#1 /vendor/magento/module-deploy/Model/Filesystem.php(172): Magento\Deploy\Model\Filesystem->compile(Object(Symfony\Component\Console\Output\ConsoleOutput))
#2 /vendor/magento/module-deploy/Model/Mode.php(139): Magento\Deploy\Model\Filesystem->regenerateStatic(Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 [internal function]: Magento\Deploy\Model\Mode->Magento\Deploy\Model{closure}()
#4 /vendor/magento/framework/App/Console/MaintenanceModeEnabler.php(85):
call_user_func(Object(Closure))
#5 /vendor/magento/module-deploy/Model/Mode.php(147): Magento\Framework\App\Console\MaintenanceModeEnabler->executeInMaintenanceMode(Object(Closure),
Object(Symfony\Component\Console\Output\ConsoleOutput), false)
#6 /vendor/magento/module-deploy/Console/Command/SetModeCommand.php(101):
Magento\Deploy\Model\Mode->enableProductionMode()
#7 /vendor/symfony/console/Command/Command.php(255): Magento\Deploy\Console\Command\SetModeCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput),
Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 /vendor/symfony/console/Application.php(893): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput),
Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 /vendor/symfony/console/Application.php(262): Symfony\Component\Console\Application->doRunCommand(Object(Magento\Deploy\Console\Command\SetModeCommand),
Object(Symfony\Component\Console\Input\ArgvInput),
Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /vendor/magento/framework/Console/Cli.php(102): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput),
Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /vendor/symfony/console/Application.php(145): Magento\Framework\Console\Cli->doRun(Object(Symfony\Component\Console\Input\ArgvInput),
Object(Symfony\Component\Console\Output\ConsoleOutput))

Thank you very much in advance

Best Answer

php -d memory_limit=-1 bin/magento deploy:mode:set production

Won't work to solve this problem.

To fix this you need to increase the PHP Memory Limit in the php.ini file on your server.

Increase it to any greater value e.g 1024M or 2G or 5G.

This will solve the problem..

Related Topic