0

i have run production command but not working

php bin/magento deploy:mode:set production

enter image description here

when I run deploy command

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

and Below type Error showing

Command returned non-zero exit code: `/opt/alt/php71/usr/bin/php -f

When i run Below deploy command and working Fine but i can not set to production mode

php bin/magento setup:static-content:deploy

enter image description here

2
  • I was facing similar issue today I had resolved it let me post answer for you Sep 25, 2019 at 19:34
  • @HassanAliShahzad Thanks for replay please update your answer here Sep 25, 2019 at 19:39

3 Answers 3

1
+50

Run below command in sequence for move website to production mode.

sudo chmod -R 0777 pub var generated
sudo php bin/magento setup:upgrade
sudo php bin/magento deploy:mode:set production -s
sudo php bin/magento setup:di:compile
sudo chmod -R 0777 pub var generated
sudo php bin/magento setup:static-content:deploy -f
sudo chmod -R 0777 pub var generated
sudo php bin/magento cache:flush
sudo chmod -R 0777 pub var generated

Note : Remove sudo if you have not access for root user

2
  • Thanks for replay ok let me try this it and update you Oct 1, 2019 at 10:08
  • should be bin/magento setup:static-content:deploy -f.
    – HoangHieu
    Oct 15, 2019 at 10:07
2

First run the following command:

php bin/magento deploy:mode:set production -s

After that you can run following in sequence:

sudo rm -rf  var/cache/* var/page_cache/* generated/*
sudo chmod -R 777 var/ generated/ pub/static/ app/etc/ pub/media/
sudo php bin/magento setup:upgrade
sudo chmod -R 777 var/ generated/ pub/static/ app/etc/ pub/media/
php  -d memory_limit=5G bin/magento setup:static-content:deploy
sudo chmod -R 777 var/ generated/ pub/static/ app/etc/ pub/media/
php -d memory_limit=5G bin/magento setup:di:compile
sudo chmod -R 777 var/ generated/ pub/static/ app/etc/ pub/media/

Let me know if still have same issue?

15
  • your command working but compilation command not working 14 % complete after stop it and process finished it prnt.sc/payubz Sep 25, 2019 at 19:52
  • you are not using my command copy my compilation command exactly Sep 25, 2019 at 19:54
  • Also run in same sequence exactly copy & paste Sep 25, 2019 at 19:55
  • i have same command as per your suggestion but not woking also production mode not set Sep 25, 2019 at 19:58
  • can you show me print screen again please? Sep 25, 2019 at 20:00
0

Remove theme folders from pub/static after setting to production mode

rm -rf pub/static/frontend/

and then run

php -dmemory_limit=6G bin/magento setup:static-content:deploy -f

OR

php -dmemory_limit=6G bin/magento setup:static-content:deploy 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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