Magento magento 开发编译脚本 sinsna Read more posts by this author. sinsna 17 Jul 2023 • 2 min read #!/bin/bash sudo php7.2 bin/magento cache:clean #sudo rm -rf pub/static/adminhtml sudo rm -rf pub/static/frontend echo '缓存文件已经删除' sudo php7.2 -dmemory_limit=4G bin/magento setup:static-content:deploy -f sudo php7.2 bin/magento cache:flush echo '已经刷新缓存' sudo chmod -R 777 pub/static/adminhtml sudo chmod -R 777 pub/static/frontend sudo chmod -R 777 var sudo chmod -R 777 generated sudo chmod -R 777 app/etc sudo chmod -R 644 app/etc/*.xml sudo chmod -R 777 vendor echo '脚本执行完成' #echo '重启PHP' #sudo service php7.2-fpm restart nowmodel=`sudo php7.2 bin/magento deploy:mode:show | awk '{print $4}'` echo -e "\033[32m注意:当前位于${branchinfo}分支,${nowmodel}模式\033[0m" 保存为dev.sh文件放在网站根目录 #!/bin/bash sudo php7.2 bin/magento cache:clean branchinfo=`git symbolic-ref --short -q HEAD` nowmodel=`sudo php7.2 bin/magento deploy:mode:show | awk '{print $4}'` if [ ${branchinfo} = 'master' ]; then echo -e "\033[32m Master分支,切换production-上线部署模式\033[0m" sudo php7.2 bin/magento deploy:mode:set -s production else echo -e "\033[31m ${branchinfo}分支,切换到developer-开发模式 \033[0m" sudo php7.2 bin/magento deploy:mode:set developer fi sudo php7.2 bin/magento maintenance:enable sudo rm -rf generated sudo rm -rf pub/static/adminhtml sudo rm -rf pub/static/frontend sudo rm -rf var/view_preprocessed sudo rm -rf var/cache sudo rm -rf var/page_cache echo '缓存文件已经删除' sudo php7.2 -dmemory_limit=4G bin/magento setup:upgrade sudo php7.2 -dmemory_limit=4G bin/magento setup:static-content:deploy -f sudo php7.2 -dmemory_limit=4G bin/magento setup:static-content:deploy -f en_US sudo php7.2 -dmemory_limit=4G bin/magento setup:di:compile #php -dmemory_limit=4G bin/magento setup:static-content:deploy -f echo '编译完成' if [ ${branchinfo} = 'master' ]; then sudo php7.2 -dmemory_limit=4G bin/magento indexer:reset sudo php7.2 -dmemory_limit=4G bin/magento indexer:reindex fi echo '索引刷新完成' sudo php7.2 bin/magento cache:flush sudo php7.2 bin/magento maintenance:disable echo '已经刷新缓存' sleep 5 sudo chmod -R 777 pub/static/adminhtml sudo chmod -R 777 pub/static/frontend sudo chmod -R 777 var sudo chmod -R 777 generated sudo chmod -R 777 app/etc sudo chmod -R 644 app/etc/*.xml sudo chmod -R 777 vendor echo '脚本执行完成' #echo '重启PHP' #sudo service php7.2-fpm restart nowmodel=`sudo php7.2 bin/magento deploy:mode:show | awk '{print $4}'` echo -e "\033[32m注意:当前位于${branchinfo}分支,${nowmodel}模式\033[0m"保存为run.sh文件放在网站根目录