While running PHP bin/magento deploy:mode:set prod

2019-09-18 05:17发布

问题:

I am using php7 with nginx

Something went wrong while compiling generated code. See the error log for details.

Command returned non-zero exit code: /usr/bin/php7.0 -f /var/www/magento2/bin/magento setup:di:compile

回答1:

try to run the failing command with the -vvv switch (for very verbose output).

/usr/bin/php7.0 -f /var/www/magento2/bin/magento setup:di:compile -vvv

with this command you should at least get a better error message than "an error occurred..."

very likely, it's just the memory_limit being too low. You can increase the memory limit for a php process by adding the -d parameter to the php command:

/usr/bin/php7.0 -d memory_limit=1G -f /var/www/magento2/bin/magento setup:di:compile

if you run deploy:mode:set production, the compilation will be startet as a sub process and you can't increase the memory limit like this (since the parameter is not passed to the sub command)

in this case, you have to increase the memory limit in your php configuration



回答2:

Command returned non-zero exit code: /usr/bin/php7.0 -f /var/www/magento2/bin/magento setup:di:compile

In Magento 2 world, this error message is widely-known as memory limit problem. That is why in Magento 2 requirement, they recommend us to set

memory_limit = 768M

That is the perfect size to run Magento 2 commands in almost situation.