To update Magento via SSH, you’ll need to use the Composer package manager, which is the recommended way to manage Magento installations. Here’s a step-by-step guide:

Prerequisites:

  1. Backup Your Store:
    • Before performing any updates, it’s crucial to back up your Magento installation and database.
  2. SSH Access:
    • Ensure that you have SSH access to your server.

Steps to Update Magento:

  1. Access Your Server:
    • Connect to your server via SSH using a terminal or command prompt.
  2. Navigate to Your Magento Root Directory:
    • Change to the directory where your Magento installation is located. This is typically your web server’s document root:
      cd /path/to/your/magento
  3. Put Your Store in Maintenance Mode:
    • While updating, it’s a good practice to put your store in maintenance mode to prevent disruptions to customers. Run:
      bin/magento maintenance:enable
  4. Update Composer Dependencies:
    • Run the following commands to update Magento and its dependencies:
      composer require magento/product-community-edition=2.x.x --no-update
      composer update

      Replace 2.x.x with the version you want to update to.

  5. Update the Database Schema and Data:
    • After updating the codebase, apply database schema and data changes:
      bin/magento setup:upgrade
  6. Compile Code (if applicable):
    • If you are in production mode, compile the code:
      bin/magento setup:di:compile
  7. Deploy Static Content (if applicable):
    • If you are in production mode, deploy static content:
      bin/magento setup:static-content:deploy
  8. Clear Cache:
    • Clear the cache to ensure that the changes take effect:
      bin/magento cache:flush
  9. Disable Maintenance Mode:
    • Disable maintenance mode:
      bin/magento maintenance:disable
  10. Verify:
    • Verify that your store is working as expected.

Important Notes:

  • Always check the Magento documentation and release notes for any version-specific instructions or requirements before performing an update.
  • Consider testing the update on a staging environment before applying it to your live store.
  • If you have custom themes or extensions, make sure they are compatible with the updated Magento version.
  • Keep regular backups of your Magento store and database in case any issues arise during the update process.