nativeInstallermagento

Upgrade Magento

Before running the commands shown on this page, you should load the Bitnami stack environment by executing the installdir/use_APPNAME script (Linux and MacOS) or by clicking the shortcut in the Start Menu under “Start -> Bitnami APPNAME Stack -> Application console” (Windows). On OS X VMs, the installation directory is /opt/bitnami and OS X VM users can click the “Open Terminal” button to run commands. Learn more about the Bitnami stack environment and about OS X VMs.

NOTE: The Approach A sections referred to below do not apply to Bitnami native installers. Users of Bitnami native installers should refer only to the Approach B sections.

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 installdir/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:

    • Approach A (Bitnami installations using system packages):

        $ cd installdir/magento
      
    • Approach B (Self-contained Bitnami installations):

        $ cd installdir/apps/magento/htdocs/
      
  • 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:

    • Approach A (Bitnami installations using system packages):

        $ sudo rm -rf installdir/magento/var/cache/*
        $ sudo rm -rf installdir/magento/var/page_cache/*
        $ sudo rm -rf installdir/magento/generated/*
      
    • Approach B (Self-contained Bitnami installations):

        $ sudo rm -rf installdir/apps/magento/htdocs/var/cache/*
        $ sudo rm -rf installdir/apps/magento/htdocs/var/page_cache/*
        $ sudo rm -rf installdir/apps/magento/htdocs/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 installdir/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 installdir/ctlscript.sh restart php-fpm
      $ sudo installdir/ctlscript.sh restart apache
    

For more information, refer to the Magento documentation.

Last modification June 16, 2021