Upgrade Magento2 via command line
In this blog, today I’m going to explain that how you can you can upgrade or update your current Magento version to latest version or specific higher version using composer and command line.
For that, you have to open terminal/command prompt.
After that go to your Magento site’s root directory in the terminal using cd command
For example, your Magento site can be in folder/directory path as /var/www/html.
So go to that directory from command line and after that, check your current Magento version with the following command.
php bin/magento —version
Running the above command will output something like this:
Magento CLI version 2.1.8
The above output shows that your current Magento version is 2.1.8.
Now if, you want to upgrade your Magento site to version 2.1.9.
For that, you have to run the following commands:
Note that, you have to be in your Magento’s directory root while running the below commands.
composer require magento/product–community–edition 2.1.9 —no–update composer update rm –rf var/di var/generation php bin/magento cache:f php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento indexer:reindex
After the upgrade, again check your Magento version with the following command:
php bin/magento —version
Output showing :
Magento CLI version 2.1.9
That’s it. Enjoy 🙂