Magento 2 – Problem Setting Production Mode and Deploying Static Content

magento2production-mode

I have a Magento 2 store which throws an error when entering production mode.

bin/magento deploy:mode:set production

Runs most the way until hitting deploy static content:

Something went wrong while deploying static content. See the error log for details.

Command returned non-zero exit code:
`/usr/bin/php7.0 -f /var/www/mage2/public_html/bin/magento setup:static-content:deploy -f en_GB en_US`

I can however run deploy static content without an error it seems.

In my logs i am getting a few errors for the theme with theme_dir not passed.

[InvalidArgumentException]
Required parameter 'theme_dir' was not passed

I am unsure why these are set to en_US however as would like them en_GB. I have all the themes set in the correct folders however i believe and am unsure how to resolve this error.

Best Answer

Change the mode and skip the compilation:

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

And once the mode is switched you can deploy static content with GB locale.

php bin/magento setup:static-content:deploy en_GB

Magento default locale is en_US so you have to define your language.

If that fails, make sure your /var and pub/ have the correct permissions

It could be that your PHP is exhausted so increasing the limit in php.ini should help but skipping the compilation and compiling after switch is a good workaround.

Also, make sure your store in use has a valid theme selected, it might be that you are using a theme that doesn't exist in the system.

Related Topic