Hi Community,
The website is in production and I am trying to minify and merge CSS and JS. My question is if it is safe to do this via command line in production mode?
and it its better to use following in Mysql
UPDATE `core_config_data` SET `value`='1' WHERE `path`='dev/js/minify_files';
UPDATE `core_config_data` SET `value`='1' WHERE `path`='dev/js/merge_files';
UPDATE `core_config_data` SET `value`='1' WHERE `path`='dev/css/minify_files';
UPDATE `core_config_data` SET `value`='1' WHERE `path`='dev/css/merge_css_files';
or
SSH to root and use these commands instead:
bin/magento config:set dev/js/minify_files 1
bin/magento config:set dev/js/merge_files 1
bin/magento config:set dev/css/minify_files 1
bin/magento config:set dev/css/merge_files 1
Thank you
It's better to use Magento CLI
php bin/magento config:set dev/css/merge_css_files 1 php bin/magento config:set dev/css/minify_files 1 php bin/magento config:set dev/js/merge_files 1 php bin/magento config:set dev/js/minify_files 1
Do not forget to deploy your static content and flush cache using following commands;
php bin/magento setup:static-content:deploy chmod 777 -R var pub generated php bin/magento cache:flush
I agree with @TutorialMagento.
It is always better to use the CLI instead of running SQL commands directly as there is a slight risk that you may have formatted the command incorrectly and corrupt the database.
And yes, you should definitely take a backup before you do this in production. If you can, try it first in your staging environment (set one up if you don't have one) before pushing it to production.
i JLHC,
Thank you for your reply. When I am running the first command through CLI, I hit an error:
SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction, query was: UPDATE `mguj_core_config_data` SET `scope` = ?, `scope_id` = ?, `path` = ?, `value` = ? WHERE (config_id=835)
Any ideas?
Depending on how high or low the innodb_lock_wait_timeout is set in your my.cnf, you may want to consider increasing it for your server.
I do hope that you are testing this in a staging environment and not in production.