Magento 2 Maintainanace guide for update via CLI

#1
composer require magento/product-community-edition 2.X.X --no-update

php70 bin/magento deploy:mode:set production --skip-compilation

php70 /bin/composer install --ignore-platform-reqs

php70 /bin/composer update --ignore-platform-reqs

php70 -d memory_limit=-1 bin/magento setup:upgrade

php70 -d memory_limit=-1 bin/magento setup:static-content:deploy

php70 -d memory_limit=-1 bin/magento setup:di:compile

php70 -d memory_limit=-1 bin/magento cache:flush

php70 -d memory_limit=-1 bin/magento indexer:reset

php70 -d memory_limit=-1 bin/magento cache:clean

php70 -d memory_limit=-1 bin/magento cache:enable

find /home/XXX/public_html/ -name ".htaccess" -type f -exec sed -i 's/FollowSymLinks/SymLinksIfOwnerMatch/g' {} ";"

php70 -d memory_limit=-1 bin/magento indexer:reindex

php70 -d memory_limit=-1 bin/magento setup:backup --db

php70 -d memory_limit=-1 bin/magento info:backups:list

php70 -d memory_limit=-1 bin/magento maintenance:disable

php70 -d memory_limit=-1 bin/magento maintenance:enable

chown -Rf USER:GROUP /home/USER/public_html/

//To run command forcefully

php70 -f bin/magento

//To run command with memory limit 4G

php70 -d memory_limit=4G bin/magento

//To run command with max memory limit

php70 -d memory_limit=-1 bin/magento cache:clean

php70 -d memory_limit=4G bin/magento setup:static-content:deploy

php70 bin/magento setup:store-config:set --base-url="[http://XXX.com/](http://XXX.com/)"

php70 bin/magento setup:store-config:set --base-url-secure="[https://XXX.com/](https://XXX.com/)"

php70 bin/magento setup:config:set --backend-frontname="gmtc"

Change domain name:

UPDATE core *config* data

SET value = 'http://xxx.com/'

WHERE path IN ('web/secure/base *url', 'web/unsecure/base* url');
#2

Updated command for Magento 2.3

sudo -su USER"

sudo php72 /bin/composer require magento/product-community-edition 2.3 --no-update

manually editing composer.json autoload section to
   "autoload": {
        "psr-4": {
            "Magento\\Framework\\": "lib/internal/Magento/Framework/",
            "Magento\\Setup\\": "setup/src/Magento/Setup/",
            "Magento\\": "app/code/Magento/",
            "Zend\\Mvc\\Controller\\": "setup/src/Zend/Mvc/Controller/"
        },
and then run composer dumpautoload.
https://github.com/magento/magento2/issues/15441
  • rm -rf var/cache/* var/page_cache/* var/generation/*

sudo php72 /bin/composer install --ignore-platform-reqs

If you use redis, then first ==> redis-cli then ==> flushall

sudo php72 -d memory_limit=-1 bin/magento setup:upgrade

sudo php72 -d memory_limit=-1 bin/magento cache:flush

find /home/ -name “.htaccess” -type f -exec sed -i ‘s/FollowSymLinks/SymLinksIfOwnerMatch/g’ {} “;”

sudo php72 -d memory_limit=-1 bin/magento setup:di:compile

sudo php72 -d memory_limit=-1 bin/magento setup:static-content:deploy

php72 -d memory_limit=-1 bin/magento indexer:reset

sudo php72 -d memory_limit=-1 bin/magento indexer:reindex

sudo php72 -d memory_limit=-1 bin/magento cache:enable

sudo php72 bin/magento deploy:mode:set developer

sudo php72 bin/magento deploy:mode:set production

#3

composer require magento/product-community-edition 2.X.X --no-update

sudo php71 bin/magento deploy:mode:set production --skip-compilation

sudo php71 /bin/composer install --ignore-platform-reqs

sudo php71 /bin/composer update --ignore-platform-reqs

sudo php71 -d memory_limit=-1 bin/magento setup:upgrade

sudo php71 -d memory_limit=-1 bin/magento setup:static-content:deploy

sudo php71 -d memory_limit=-1 bin/magento setup:di:compile

sudo php71 -d memory_limit=-1 bin/magento cache:flush

sudo php71 -d memory_limit=-1 bin/magento indexer:reset

sudo php71 -d memory_limit=-1 bin/magento cache:clean

sudo php71 -d memory_limit=-1 bin/magento cache:enable

find /home/XXX/public_html/ -name “.htaccess” -type f -exec sed -i ‘s/FollowSymLinks/SymLinksIfOwnerMatch/g’ {} “;”

sudo php71 -d memory_limit=-1 bin/magento indexer:reindex

sudo php71 -d memory_limit=-1 bin/magento setup:backup --db

sudo php71 -d memory_limit=-1 bin/magento info:backups:list

sudo php71 -d memory_limit=-1 bin/magento maintenance:disable

sudo php71 -d memory_limit=-1 bin/magento maintenance:enable

chown -Rf USER:GROUP /home/USER/public_html/

//To run command forcefully

sudo php71 -f bin/magento

//To run command with memory limit 4G

sudo php71 -d memory_limit=4G bin/magento

//To run command with max memory limit

sudo php71 -d memory_limit=-1 bin/magento cache:clean

sudo php71 -d memory_limit=4G bin/magento setup:static-content:deploy

sudo php71 bin/magento setup:store-config:set --base-url=“http://XXX.com/

sudo php71 bin/magento setup:store-config:set --base-url-secure=“https://XXX.com/

sudo php71 bin/magento setup:config:set --backend-frontname=“gmtc”

Change domain name:

UPDATE core config data

SET value = ‘http://xxx.com/

WHERE path IN (‘web/secure/base url’, 'web/unsecure/base url’);

#4

find app/code var/view_preprocessed vendor pub/static app/etc generated/code generated/metadata ( -type f -or -type d ) -exec chmod u-w {} + && chmod o-rwx app/etc/env.php && chmod u+x bin/magento

#5

# find app/code var/view_preprocessed vendor pub/static app/etc generated/code generated/metadata \( -type f -or -type d \) -exec chmod u-w {} + && chmod o-rwx app/etc/env.php && chmod u+x bin/magento



composer require magento/product-community-edition 2.X.X --no-update

sudo php72 bin/magento deploy:mode:set production --skip-compilation

sudo php72 /bin/composer install --ignore-platform-reqs

sudo php72 /bin/composer update --ignore-platform-reqs

sudo php72 -d memory_limit=-1 bin/magento setup:upgrade

sudo php72 -d memory_limit=-1 bin/magento setup:static-content:deploy

sudo php72 -d memory_limit=-1 bin/magento setup:di:compile

sudo php72 -d memory_limit=-1 bin/magento cache:flush

sudo php72 -d memory_limit=-1 bin/magento indexer:reset

sudo php72 -d memory_limit=-1 bin/magento cache:clean

sudo php72 -d memory_limit=-1 bin/magento cache:enable

find /home/XXX/public_html/ -name “.htaccess” -type f -exec sed -i ‘s/FollowSymLinks/SymLinksIfOwnerMatch/g’ {} “;”

sudo php72 -d memory_limit=-1 bin/magento indexer:reindex

sudo php72 -d memory_limit=-1 bin/magento setup:backup --db

sudo php72 -d memory_limit=-1 bin/magento info:backups:list

sudo php72 -d memory_limit=-1 bin/magento maintenance:disable

sudo php72 -d memory_limit=-1 bin/magento maintenance:enable

chown -Rf USER:GROUP /home/USER/public_html/

//To run command forcefully

sudo php72 -f bin/magento

//To run command with memory limit 4G

sudo php72 -d memory_limit=4G bin/magento

//To run command with max memory limit

sudo php72 -d memory_limit=-1 bin/magento cache:clean

sudo php72 -d memory_limit=4G bin/magento setup:static-content:deploy

sudo php72 bin/magento setup:store-config:set --base-url=“http://XXX.com/”

sudo php72 bin/magento setup:store-config:set --base-url-secure=“https://XXX.com/”

sudo php72 bin/magento setup:config:set --backend-frontname=“gmtc”

Change domain name:

UPDATE core config data

SET value = ‘http://xxx.com/’

WHERE path IN (‘web/secure/base url’, 'web/unsecure/base url’);

#6

Setting file/folder commands in Magento 2



find . -type f -exec chmod 644 {} \;                        // 644 permission for files

find . -type d -exec chmod 755 {} \;                        // 755 permission for directory 

find ./var -type d -exec chmod 777 {} \;                // 777 permission for var folder    

find ./pub/media -type d -exec chmod 777 {} \;

find ./pub/static -type d -exec chmod 777 {} \;

chmod 777 ./app/etc

chmod 644 ./app/etc/*.xml