Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top