This is the sequence of commands I use to update a Composer-based Magento 2 Community Edition store to a newer release over SSH. It was written for Magento 2.2, and the example moves to 2.2.6. Replace 2.2.6 with the version you want.
Before you start Back up the database and the files. setup:upgrade changes the database and there’s no undo, and the “hard fix” further down deletes vendor/ and var/ completely. Run everything from the Magento root, the folder that contains composer.json and bin/magento, as the user that owns the Magento files rather than root. Put the store in maintenance mode with php bin/magento maintenance:enable, so visitors don’t see a half-updated site. Turn it off with php bin/magento maintenance:disable at the end. Stay within one release line. These steps are for moves like 2.2.5 to 2.2.6. Jumping to a new minor version such as 2.3 usually needs more changes in composer.json, and sometimes a newer PHP version, so read the release notes first. The update composer require magento/product-community-edition 2.2.6 --no-update composer update rm -rf var/di var/generation var/cache var/view_preprocessed generated/* php bin/magento cache:clean php bin/magento cache:flush php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento indexer:reindex php bin/magento deploy:mode:set production composer require magento/product-community-edition 2.2.6 --no-update changes the required Magento version in composer.json without downloading anything yet. composer update downloads the new version and its dependencies. Note that it updates every package composer.json allows, not only Magento, so third-party extensions can move to newer versions too. rm -rf var/di var/generation var/cache var/view_preprocessed generated/* removes generated code, cache and preprocessed theme files left over from the old version. Magento 2.1 kept generated code in var/di and var/generation; 2.2 moved it to generated/. Listing both covers a store that is coming from 2.1. php bin/magento cache:clean and php bin/magento cache:flush empty Magento’s cache. cache:clean removes Magento’s own entries, cache:flush clears the whole cache storage. php bin/magento setup:upgrade updates the database schema and data to match the new module versions. php bin/magento setup:di:compile generates the dependency injection configuration and the generated classes again. php bin/magento indexer:reindex rebuilds the indexes. php bin/magento deploy:mode:set production switches the store to production mode. While doing that, Magento compiles the code and deploys the static files (CSS, JavaScript, images) itself, which is why there’s no separate setup:static-content:deploy in this list. When it finishes, check the storefront and the admin.
...