virtualMachinemagento

Upgrade Magento

It is strongly recommended to create a backup before starting the update process. If you have important data, create and try to restore a backup to ensure that everything works properly.

You can upgrade the application only without modifying any other stack components, as described below:

Step 1: Create a backup

Before making any change to the Magento installation, create a backup of the application data.

Step 2: Prepare for the upgrade

  • Ensure that you establish a PHP memory limit of at least 2 GB, in /opt/bitnami/php/etc/php.ini:

      memory_limit = 2G
    
  • Temporarily disable cron jobs as documented in the Configure scheduled tasks section.

  • Enable maintenance mode:

      $ sudo magento-cli maintenance:enable
    
  • Visit the Magento Marketplace and obtain your public/private access key pair using the “My Account -> Connect -> Developers -> Secure Keys” section. If you don’t have a Magento Marketplace account, create one here.

    Magento upgrade

Step 3: Update Magento to the desired version

  • Navigate to the Bitnami installation directory in the command-line:

      $ cd /opt/bitnami/magento
    
  • Update your Magento requirement to the new desired version in composer.json. At this point, you will be asked to provide credentials to access repo.magento.com. Enter the authentication keys obtained in Step 2.

      $ sudo cp composer.json composer.json.bak
      $ sudo composer require magento/product-community-edition=VERSION --no-update
    
  • Update your installation. You will also be asked to provide the same credentials provided in the previous step.

      $ sudo composer update
    

    NOTE: If you see an error similar to this while executing the above command, you will need to increase the PHP memory_limit configuration to an even higher value.

    Fatal error: Allowed memory size of 21610612736 bytes exhausted
    
  • Clear the var/ and generated/ directories:

      $ sudo rm -rf /opt/bitnami/magento/var/cache/*
      $ sudo rm -rf /opt/bitnami/magento/var/page_cache/*
      $ sudo rm -rf /opt/bitnami/magento/generated/*
    
  • Upgrade the Magento database schema:

      $ sudo magento-cli setup:upgrade
    
  • Finally, disable maintenance mode to complete the upgrade:

      $ sudo magento-cli maintenance:disable
    

Step 4: Complete upgrade

  • Reset to the previous value of the PHP memory limit in /opt/bitnami/php/etc/php.ini:

      memory_limit = 2G
    
  • Re-enable cron jobs as documented in the Configure scheduled tasks section.

  • Disable maintenance mode:

      $ sudo magento-cli maintenance:disable
    
  • Restart Apache and PHP-FPM:

      $ sudo /opt/bitnami/ctlscript.sh restart php-fpm
      $ sudo /opt/bitnami/ctlscript.sh restart apache
    

For more information, refer to the Magento documentation.

Last modification February 9, 2023