How to Upgrade to Magento 2.3: Command-line upgrade

Magento 2.3 Upgrade Requirements

You must meet the requirements to install/upgrade Magento 2.3.

1, Operating systems, Web servers, Database and php

To install Magento 2.3, you need a Linux-based operating system (Linux x86-64), such as RedHat Enterprise Linux (RHEL), CentOS, Ubuntu, Debian, and similar.

Also, the Web servers for Magento 2.3 is either Apache 2.2/2.4 or nginx 1.x.

For the Database, Magento 2.3 is compatible with MySQL 5.6 or 5.7, MySQL NDB Cluster 7.4.*, MariaDB 10.0, 10.1, 10.2, Percona 5.7, and other binary-compatible MySQL technologies.

Magento 2.3 only support php 7.1.3 and later, or php 7.2.

If you are reading how to upgrade to Magento 2.3 from Magento 2.2.x version, you can safely pass this step.

2, Version requirement to upgrade

To upgrade to Magento 2.3, you need a current version of Magento to be 2.1.4 and later. If you are running a 2.1.3 and earlier version, you must upgrade to version 2.1.4 or later before you continue.

Prerequisites for Magento 2.3 Upgrade

Before running any System upgrade (which includes Magento 2.3 Upgrade), you must complete the task:

1, Set up cron for upgrade

To upgrade your system, you must have two cron jobs. Each cron job should run every minute.

The Magento crontab is inside #~ MAGENTO START and #~ MAGENTO END comments in your crontab.

To create the Magento crontab:

  1. Log in as, or switch to, the Magento file system owner.
  2. Change to your Magento installation directory.
  3. Enter the following command:
    1 php bin/magento cron:install [--force]

Use –force  to rewrite an existing Magento crontab.

After all, you can view the crontab via command:

1 crontab -l

2, Set ulimit for the webserver user

Magento requires you to set the ulimit for the Magento file system user to a value of 65536 or more.

Why do you need to set ulimit? Because a rollback to a previous backup can silently fail, resulting in incomplete data being written to the file system or database.

To set ulimit, you only need to follow this:

  1. Open in a text editor:
    1 /home/<username>/.bashrc
  2. Add the following line:
    1 ulimit -s 65536
  3. Save your changes to .bashrc and exit the text editor.

3, Set a value for DATA_CONVERTER_BATCH_SIZE

Magento 2.3 is the unique version with security enhancements that needs converting data from serialized format to JSON encoded format. If you have a large amount of data, you can improve performance by setting the value of an environment variable, DATA_CONVERTER_BATCH_SIZE. By default, it’s set to a value of 50,000.

You can set value for DATA_CONVERTER_BATCH_SIZE in a bash shell prompt:

1 $ export DATA_CONVERTER_BATCH_SIZE <value>

The value depends on you, we suggest you set to 100000.

After upgrading to Magento 2.3, you can change back the variable as follows:

1 $ unset DATA_CONVERTER_BATCH_SIZE

Command-line upgrade

Also, you can upgrade Magento 2.3 with a command line.

Step 1 Backup the existing composer.json file in the Magento installation directory.

Step 2 Remove any unnecessary packages before upgrading to Magento 2.3.

1 $ composer remove --dev sjparkinson/static-review fabpot/php-cs-fixer --no-update

Step 3

Then you need to deactivate the Magento Open Source update.

1 $ composer remove magento/product-community-edition --no-update

Step 4

Indicate to Magento 2.3

1, For Magento Open Source

1 $ composer require magento/product-community-edition=2.3.0 --no-update

2, For Magento Commerce

1 $ composer require magento/product-enterprise-edition=2.3.0 --no-update

Specify additional packages

1 $ composer require --dev phpunit/phpunit:~6.2.0 friendsofphp/php-cs-fixer:~2.10.1 lusitanian/oauth:~0.8.10 pdepend/pdepend:2.5.2 sebastian/phpcpd:~3.0.0 squizlabs/php_codesniffer:3.2.2 --no-update

Step 5

Open composer.json and edit the “autoload

"autoload": {
"psr-4": {
"Magento\\Framework\\": "lib/internal/Magento/Framework/",
"Magento\\Setup\\": "setup/src/Magento/Setup/",
"Magento\\": "app/code/Magento/",
"Zend\\Mvc\\Controller\\": "setup/src/Zend/Mvc/Controller/"
},
...
}

Step 6

Modify the Magento updater

You need to modify the Magento updater if it is installed (which located in <Magento install dir>/update). First, you need to backup and remove the old updater. Then, create a Composer project.

1, For Magento Open Source

1 $ composer create-project --repository=https://repo.magento.com magento/project-community-edition=2.3.0 temp_dir --no-install

2, For Magento Commerce

1 $ composer create-project --repository=https://repo.magento.com magento/project-enterprise-edition=2.3.0 temp_dir --no-install

Finally, move the new project to <Magento install dir>/update directory:

1 mkdir update
2 $ mv temp_dir/update <Magento install dir>/update
3 $ rm -rf temp_dir

Step 7

Check metadata in “name“, “version“, and “description” fields in the <Magento install dir>/composer.json file. If everything is okay, apply update.

1 $ composer update

Step 8

Clear caches and generated content

1 $ rm -rf <Magento install dir>/var/cache/*
2 $ rm -rf <Magento install dir>/var/page_cache/*
3 $ rm -rf <Magento install dir>/generated/code/*

Step 9

Update the database schema and data

1 $ php bin/magento setup:upgrade

Step 10

Disable maintenance mode

1 $ php bin/magento maintenance:disable