0

When the Magento2 site is in production mode and I want to modify some html/phtml/php/js files how can I update the edited files while remaining in production mode?

For the moment I have done this:

$ php bin/magento setup:upgrade
$ php bin/magento setup:di:compile
$ php bin/magento c:f

Finally I ran this command:

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

When I ran the "setup: upgrade" command I saw that my files written by the production mode had already disappeared and the site did not work well.

Finally I ran the "setup: static-content: deploy" command and it returned me an error saying that it was not possible to compile the less files. Consequently I had to go back to default mode.

What could have been the mistake?

1

I would suggest below steps to deploy your changes on production server.

  1. Enabled the maintenance mode.
  2. Run below commands:

PHP bin/magento setup:upgrade

PHP bin/magento setup:di:compile

PHP bin/magento setup:static-content:deploy -f

If require provide correct permission for var, generated and pub folders.

If you get any error in any of the commands, you need to fix those issues on the staging server.

These are the standard Magento steps for production deployment.

Please let me know if you need any other help.

4
  • Thanks for this reply! One more question, for example if i want update only specific files for all stores can i ran a custom command for deploy only specific files for all store? How can i do?
    – Jackom
    Mar 1 at 12:07
  • Support if you want to change anything in template file like phtml or block (.php) files then you need to flush the cache and you can see the changes (if there is no any other cache installed and running). If you did the changes in JS/CSS file then I would suggest running all the commands. Apart from this if you did changes in di or any etc folder file then you have to run setup:upgrade and setup:di:compile commands.
    – Nits
    Mar 1 at 12:11
  • Ok, perfect man! Thank you for now :)
    – Jackom
    Mar 1 at 12:14
  • Welcome @Jackom
    – Nits
    Mar 2 at 7:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.