Upgrade Magento

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 "/opt/bitnami/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 /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:

    • Approach A (Bitnami installations using system packages):

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

        $ cd /opt/bitnami/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 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 /opt/bitnami/magento/var/cache/*
        $ sudo rm -rf /opt/bitnami/magento/var/page_cache/*
        $ sudo rm -rf /opt/bitnami/magento/generated/*
    • Approach B (Self-contained Bitnami installations):

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

For more information, refer to the Magento documentation.

Last modification December 21, 2022