1

Recently, we have gone live a website which was built in Magento 2.3.1. After release we did some changes in the code and also added some modules locally. Then the code was pushed to the live server and executed the following commands on the terminal :

  • sudo git stash
  • sudo git stash clear
  • git checkout development
  • git pull origin development
  • sudo php bin/magento maintenance:enable
  • touch maintenance.enable
  • sudo chmod -R 777 var/ generated
  • sudo rm -rf var/ generated
  • sudo php bin/magento cache:flush
  • sudo php bin/magento setup:upgrade
  • sudo php bin/magento setup:di:compile
  • sudo php bin/magento setup:static-content:deploy
  • sudo chmod -R 777 var/ generated/ app/ pub/
  • sudo rm -rf maintenance.enable
  • sudo php bin/magento maintenance:disable
  • sudo rm -rf maintenance.html
  • sudo chmod -R 777 var/ generated/ app/ pub/

After one hour, there were issues in placing the order, adding subscriptions etc. On analysis we find that there were no permission for the var folder. we gave the permission and all issues were fixed.

I dont know why this happened as we already gave the permission after the deployment commands.

Can someone help me resolve this or tell me the CORRECT steps to be followed in a production server which deploying new changes???

  • don't just throw around with "chmod 777" like it's candy! this is a huge security issue! – Philipp Sander Dec 5 '19 at 9:14
0

use below command from Magento root, for the right permission

sudo find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} \;
sudo find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} \;

sudo chown -R [your Magento user]:[www-data server group] . if my magento user is named magento_apache and group is www-data then command will be as below:

sudo chown -R magento:www-data .
0

You have to run chown after all commands.

Usually when you run commands like not owner of Magento files, some ownership will change.

So just add

chown your-magento-user:server-group

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.