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: We are in the process of modifying the file structure and configuration for many Bitnami stacks. On account of these changes, the file paths stated in this guide may change depending on whether your Bitnami stack uses native Linux system packages (Approach A), or if it is a self-contained installation (Approach B). To identify your Bitnami installation type and what approach to follow, run the command below:

 $ test ! -f "installdir/common/bin/openssl" && echo "Approach A: Using system packages." || echo "Approach B: Self-contained installation."

The output of the command indicates which approach (A or B) is used by the installation, and will allow you to identify the paths, configuration and commands to use in this guide. Refer to the FAQ for more information on these changes.

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 January 22, 2021