How to prepare Magento 2.3 for 2.4

The Magento 2.4 branch introduces new System Requirements that you’ll need to implement before you can upgrade from 2.3. So, in this video I’ll go over those requirements and how to set them up.


This video serves as a “Part 2” to my How to install Magento 2.3 and build a web server tutorial from 2018. Which might make some of you ask:

Hey Craig, why not just do a video on upgrading 2.3 straight to 2.4?

It’s a fair question to ask, with a simple answer. New branches are buggy in nature. For many others (including myself), it’s a business risk upgrading to a new branch. We don’t want to be the “guinea pigs” that find and report the issues. Therefore, we’ll wait for fixes to roll out before making the switch.


Some Magento 2.4 System Requirements are incompatible with Magento 2.3. Therefore, we are limited to how far we can upgrade.

This means that upgrading from Magento 2.3 to 2.4 would be quite a jarring experience. In that you’d have to upgrade your System and your Magento installation at the same time. That’s too many points of failure for my liking.

I’m crossing my fingers that the 2.3 branch will eventually support 2.4 System Requirements so that I can break up the update over several small sessions - As opposed to one big one.

A quick note on backups

We’ll be upgrading parts of the Operating System and the services that run on it. This means that your typical Magento backup is useless if you run into any system related issues.

If you have the ability to backup your Operating System (like I do with a Digital Ocean Snapshot), then use them. You can never have enough backups.

Update Ubuntu OS

You should try and get into the habit of running regular Ubuntu Updates and package Upgrades. So, let’s start here. Luckily, this procedure can be broken down into 3 steps.

For the remainder of this video, I’ll be running all commands as the “superuser”.

First, update your repositories with:

sudo apt update

Then upgrade your packages with:

sudo apt upgrade -y

(Note, that the “-y” flag simply auto-confirms “yes” to any “are you sure” questions.)

Sometimes you’ll be prompted with a question that asks if you want to install the default configuration for certain applications. I’m not sure if it’s the correct answer or not, but I’ve always allowed it to do this.

Finally, clean up any applications that are no longer depended on with:

Oops: I typo’d this next command in the video. Don’t make the same mistake!

sudo apt autoremove

Need More Help? I’m not a DevOps guy. So, if you run into any issues with this then checkout a forum dedicated to Ubuntu called

Upgrade Ubuntu to 20.x (Optional - Requires Extra Work)

When I originally wrote this tutorial, I included this step to Upgrade Ubuntu to version 20.x. However, I learned the hard way that doing this will also upgrade MySQL from 5 to 8 - Which is not compatible with Magento 2.3.

If you still want to upgrade Ubuntu and go through the headache of downgrading MySQL from 8 to 5 then I’ll include the command in the article. Otherwise, skip this step.

Important Notes:

  1. This is about a 20-30 minute process. Stay close for any prompts that require your attention.
  2. This Upgrading to Ubuntu 20.04 will replace 5.x with 8.x. However, 8.x is not compatible with Magento 2.3. So, if you do upgrade Ubuntu then you’ll be forced to downgrade MySQL after - Which is not documented here.

To initiate an Ubuntu Upgrade, run the following:

sudo do-release-upgrade

Upgrade to MySQL 5.7

So, Magento 2.4 adds support for MySQL 8 and drops support for MySQL 5.6. But it still supports MySQL 5.7. And Magento 2.3 supports MySQL 5.7 but not MySQL 8. This means, that MySQL 5.7 is compatible with both versions - Thankfully.

Magento Version MySQL 5.6 MySQL 5.7 MySQL 8
2.3.x Yes* Yes No
2.4.x No Yes* Yes

*Denotes: Compatible, but not recommended/tested

What’s also good news is that Updating the Ubuntu repositories and Upgrading the packages we did in the first section, will have automatically updated MySQL to 5.7. You can verify this when you log into phpMyAdmin as the root user or by typing:

mysql -V

Update Magento to latest 2.3.x

Thankfully, upgrading Magento within the same branch is very simple, compared to changing branches. Because some fixes and changes get shared between the 2.3 and 2.4 at the same time, there will be less changes to adapt to when you’re ready to make the big jump.

For now, I’ll be updating from Magento 2.3.5p2 to the 2.3.6 (which is the current latest version in the 2.3 branch at the time of creating this).

As of October 2020, these are my personal steps whenever I install or upgrade something new.

Make sure to switch to the “magento” user for this next section. You can switch users by using:

su magento

And then navigate to your Magento root directory with:

cd /var/www/html/

Step 1: Enable Maintenance Mode

bin/magento maintenance:enable

Step 2: Grab the 2.3.6 composer project

composer require magento/product-community-edition=2.3.6 --no-update

Step 3: Update composer

composer update

Step 4: Manually remove cached folders

rm -rf var/cache/* var/page_cache/* generated/code/* pub/static/frontend/*

Step 5: Flush Redis

redis-cli flushall

Step 6: Update Database Schema

bin/magento setup:upgrade

Step 7: Compile new codes changes

bin/magento setup:di:compile

Step 8: Redeploy Static Content (note to change your own locales)

bin/magento setup:static-content:deploy en_US en_GB -f

Step 9: Clean the cache

bin/magento cache:clean

Step 10: Flush the cache

bin/magento cache:flush

Step 11: Flush Redis (again)

redis-cli flushall

Step 12: Disable Maintenance Mode

bin/magento maintenance:disable

At this point, exit out of “magento” user back to the “superuser” by typing:


Upgrade to PHP 7.3

As a reminder, the Magento 2.3 branch does not support PHP 7.4 which is a shame. So, if you’re still running PHP 7.2 then let’s at least get it onto 7.3.

For your convenience, here’s a simple copy and paste of the modules you’ll need to install:

sudo apt install php7.3 libapache2-mod-php7.3 php7.3-mysql php7.3-soap php7.3-bcmath php7.3-xml php7.3-mbstring php7.3-gd php7.3-common php7.3-cli php7.3-curl php7.3-intl php7.3-zip php7.3-mbstring php7.3-gettext zip unzip -y

The new version of PHP will use default configurations, so be sure to edit the new file and make any changes where you see fit. So open the PHP 7.3 pnp.ini file with:

sudo nano /etc/php/7.3/apache2/php.ini

Use your Arrow or Page Up/Down keys to work your way down the file and find “date.timezone =”. You’ll need to add your server’s time zone. Use the Supported List linked in the article for your setup. In my case, it would be Europe/London.

Then, find “memory_limit” and replace “128M” with an appropriate value. Because this is a 4GB Server, I’ll set this to “4G”.

Now save your changes by press Ctrl+X to exit, Y to save and Enter to confirm.

Once you’ve finished installing and configuring PHP 7.3, you’ll need to disable PHP 7.2 with:

sudo a2dismod php7.2

And enable PHP 7.3 with:

sudo a2enmod php7.3

Followed by the restart of Apache:

sudo systemctl restart apache2

You can confirm you’re on the new version by entering:

php -v

Important: If your version of php is still showing 7.2.x, then you also need to use the following command to switch to the new version: sudo update-alternatives --config php followed by restarting apache2 again.

For the sake of a little house-keeping, remove PHP 7.2 from your Operating System by running:

sudo apt purge php7.2-common -y

But of course, this step is optional.

Install Elasticsearch 7.6

If you’ve not yet installed Elasticsearch 7.6 on your web server, you’ll need to before upgrading to Magento 2.4. I have a standalone video dedicated to this topic. So, rather than repeat myself just head over to How to install and setup Elasticsearch for Magento 2 (Ubuntu).

Upgrade or Replace 3rd Party Modules

Finally, you’ll want to Upgrade any 3rd party modules you have installed so that they’re compatible with the new environment. For example, you might have a cool module that you use at the checkout which doesn’t work with PHP 7.4. If you’re module has been built by a reputable company then the latest version of that module will support Magento 2.4.

However, if you’ve built the module yourself or it’s no longer supported by the company you obtained it from then you’ll need to find a suitable replacement. These are the kind of things that will cause you a headache come crunch time. So, now’s a great time to get ahead of it.


So, to reiterate… There’s currently is no way to fully prepare our System for a seamless upgrade experience. All we can do right now is meet the process half-way and hope that Magento will include support to fully upgrade to PHP 7.4 and MySQL 8 whilst still within the 2.3 branch.

Anyway, until next time. Take care

Useful References: