1

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?

asked Mar 1, 2021 at 11:10

1 Answer 1

3

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.

answered Mar 1, 2021 at 12:00
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? Commented Mar 1, 2021 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. Commented Mar 1, 2021 at 12:11
  • Ok, perfect man! Thank you for now :) Commented Mar 1, 2021 at 12:14
  • Welcome @Jackom Commented Mar 2, 2021 at 7:37

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.