4

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

20
  • Is the compilation successful? Commented Apr 1, 2019 at 9:03
  • Yes, it says "Generated code and dependency injection configuration successfully". (but only if I do --skip-compilation and then setup:di:compile). But then the page is messed up, though. Commented Apr 1, 2019 at 9:07
  • Give read and write permission to "generated", "Var", "app/etc" and "pub/static" folder. Commented Apr 1, 2019 at 9:18
  • Hm, these folders already have read/write permission. Commented Apr 1, 2019 at 9:21
  • Can you please check your log files? Can you deploy the files once again in production mode? Are you getting any 404 errors in your browser console? Commented Apr 1, 2019 at 9:25

4 Answers 4

1

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..

0

You should press command

sudo chmod -R 777 var/ pub/ 
0
0

You need to run this command:

chmod -R 777 var pub generated 

Please let me know if it works!

0

I got a similar error when switching to production mode from developer mode.

enter image description here

To fix it I ran following commands to give proper permissions to files and directories.

sudo find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} + sudo find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} + sudo chown -R :www-data . sudo chmod u+x bin/magento 

After this is issue is fexed.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.