Skip to content

Instantly share code, notes, and snippets.

@haljeshi
Last active July 21, 2020 06:48
Show Gist options
  • Save haljeshi/5f4c8243792b96731efddca4aa77c7f1 to your computer and use it in GitHub Desktop.
Save haljeshi/5f4c8243792b96731efddca4aa77c7f1 to your computer and use it in GitHub Desktop.
I use this shell script whenever Magento 2 is behaving strangely. It takes a long time to execute (mainly due to deploying static content), but it's a good last resort which usually solve my problem.
#!/bin/sh
RED='\033[0;31m'
NC='\033[0m'
echo "${RED}Deleting pub/static ${NC}"
rm -r pub/static/*
echo "${RED}Deleting var/cache ${NC}"
rm -r var/cache/
echo "${RED}Deleting var/composer_home ${NC}"
rm -r var/composer_home/
echo "${RED}Deleting var/generation ${NC}"
rm -r var/generation/
echo "${RED}Deleting var/page_cache ${NC}"
rm -r var/page_cache/
echo "${RED}Deleting var/view_preprocessed ${NC}"
rm -r var/view_preprocessed/
echo "${RED}Upgrading... ${NC}"
bin/magento setup:upgrade
echo "${RED}Compiling... ${NC}"
bin/magento setup:di:compile
echo "${RED}Deploying... ${NC}"
bin/magento setup:static-content:deploy -f
echo "${RED}chowing...${NC}"
sudo chown -R $USER:www-data .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment