I am working on mageno 2.1.10 and I have tried setting mod to production from development by using the following solutions:
php bin/magento deploy:mod:set production
And it gave me the following error:
Something went wrong while deploying static content. See the error log for details.
Command returned non-zero exit code:
/usr/bin/php5.6 -f /var/www/html/Katherine/bin/magento setup:static-content:deploy en_US
But There were no errors in error_log
After this error I have entered the following commands in terminal:
php bin/magento s:d:c (For di compile) php bin/magento s:s:d (For static-content deploy)
And then some of the js and css were not loading on frontend.
After the above solution didn't work for me then I have again set mod to developer and deployed static content which brough my store back to life.
Then I have tried the following code for setting it to production mode:
bin/magento setup:upgrade; bin/magento indexer:reindex; bin/magento deploy:mode:set production -s; bin/magento setup:di:compile; bin/magento setup:static-content:deploy
By doing this the frontend totally broke and none of the css/js were being loaded.
Also tried these in Database:
UPDATE `core_config_data` SET `value`='0' WHERE `path`='dev/js/merge_files'; UPDATE `core_config_data` SET `value`='0' WHERE `path`='dev/js/enable_js_bundling'; UPDATE `core_config_data` SET `value`='0' WHERE `path`='dev/js/minify_files'; UPDATE `core_config_data` SET `value`='0' WHERE `path`='dev/css/merge_css_files'; UPDATE `core_config_data` SET `value`='0' WHERE `path`='dev/css/minify_files';
This too didn't help and finally I ended up by setting it to developer mod.
I have tried the answer provided by "Ayaz" on local host and this seems to be working fine. But on live server none of the css or js are being loaded
Following are the errors in browser console after trying this solution on live server:
CSS: Refused to apply style from 'website.com/pub/static/frontend/Pack/Theme/en_US/ThousandMonkeys_SocialButtons/css/social.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
JS: Refused to execute script from 'website.com/pub/static/frontend/Pack/Theme/en_US/owl.carousel/owl.carousel.min.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
There also some js files with console error : "net::ERR_ABORTED"
I have checked the browser console and it is loading some css and js files which are (I think) from Magento base. The ones which are getting 404 in console are all the custom module's css/js
When in developer mode, I have tried to find the files in pub/static which were not found/deployed in production mode. These files were all shown as a link in FTP (FileZilla).
So now I have disabled all the modules that are in app/code by adding Zeros for them in config.php. I have changed the theme to Magento Blank from admin. But still, when setting mod to production is ends up with the same error:
Command returned non-zero exit code: /usr/bin/php5.6 -f /var/www/html/Katherine/bin/magento setup:static-content:deploy en_US
P.S: I need to enable production mod in order to get minified css/js/html
How to debug and where should I look to fix this?
Is there any way to minify js in developer mode itself?