Learn Magento 2.4 Installation On Ubuntu 20.04

Regardless of whether it’s B2B or B2C, an eCommerce platform is the backbone of an online enterprise. The best eCommerce platform also promotes the mechanism of the market interaction processes with clients, workers, and customers. Therefore, you can’t survive online if you don’t have a strong e-commerce site. Thus, in widening and growing the market, the right eCommerce platform plays a very important role, like Magento. In this blog, we’ll learn Magento 2.4 Installation On Ubuntu 20.04. You can also follow my blogs for Magento2.4 Installation on Windows and macOS.

You might ask why, although we have other hosting providers. I choose Magento as a platform for eCommerce. And AWS as a hosting provider. So, let’s just start to answer this simple question.

What’s The Magento, Exactly?

Magento is an open-source eCommerce platform. That provides online shoppers with a versatile shopping cart interface. And also provides control over their online store’s look, content, and usability of their online store. Therefore, it facilitates effective marketing, optimization of search engines, and tools for catalog management.

Why We’re Using AWS?

Generally, Cloud Computing allows an eCommerce platform to cater to the changing market demand and scenarios. It also offers scalable technology tailored to business needs. And allows upscale or downscale facilities depending on demand and traffic.

Additionally, Amazon Web Services (AWS) is the most advance and widely acceptable cloud platform in the world. That provides more than 175 fully integrated data center facilities worldwide. Furthermore, A million users use AWS to cut costs, to make themselves more agile, and to innovate faster.

Installation Requirements For Magento 2.4:

Operating systems (Linux x86-64)

  • Distributions of Linux, including RedHat Enterprise Linux (RHEL), CentOS, Ubuntu, Debian, etc.

Memory requirement

  • Magento2 requires 2GB or higher RAM. 


  • Composer 2.x cannot be supported by Magento.

Web servers

  • Apache 2.4
  • Nginx 1.x


  • MySQL 8.0
  • MariaDB 10.4


Magento supports PHP 7.4.0


  • As of 2.4.0 Magento, MySQL is no longer available for search purposes. You’re supposed to use Elasticsearch.
  • Elasticsearch 2.x, 5.x, and 6.x are no longer supported by Magento.

To get detailed information about system requirements, just visit the mentioned link: https://devdocs.magento.com/guides/v2.4/install-gde/system-requirements.html

What We’re Going To Use:

  • OSUbuntu 20.04
  • SERVERApache 2
  • RAM1 GB (We’re using 1GB of RAM, so a swap memory is required)
  • PHP: 7.4
  • MY SQL8.0
  • Composer: 1.10
  • Elasticsearch: 7.10

Magento 2.4 Installation On AWS

So let’s move to the installation part.

STEP 1: Creation of AWS Account

(i) To start with, create a new AWS account by using Sign-up. 

(ii) And then log in to your AWS account by Sign-in.

(iii) Also, select the webserver location ie AWS region from the list available. where you want to launch the EC2 instance. The option is at the top of the bar on the right-hand side.

STEP 2: Creation of EC2 Instance.

(i) After your account has been successfully createdSelect the EC2 among the available AWS services. or you can search for an EC2 service in the search box.

(ii) And then Select the Launch Instance button from the dropdown menu.

(iii) Select the server ie, Ubuntu Server 20.04 LTS by scroll down or you can directly search in the search box.

(iv) Now choose the Instance type and click on the tab, Next: Configure Instance Details.

(v) After the above steps, select the number of EC2 Instances, you want to run and then choose the tab, Next: Add Storage.

(vi) Now add up the storage as per your requirement and select the tab, Next: Add Tags.

(vii) Add tags and choose the tab, Next: configure security group.

(viii) Now, Click Add rule in configure security group, and ADD the following :

SSH, HTTP,  and HTTPS – select anywhere in the source column for all rules. Thus, after adding up the rules, select the review, and launch tab.

(ix) Under this step, review the instance launch to recheck your Instance settings one more time and if everything goes right, then select the launch button.

(x) This step is concerned with creating a key pair (It’s better to use the domain name for the key pair name) and after the creation, download the key pair.

(xi) Once the pem file is downloaded, adhere to the terms and conditions of the AWS, and click the Launch buttonYou’ll see the image as below.

(xii) Scroll down and press the “View launch log button and then click the Instance Id to view your instance after the successful launch of the instance as seen in the images below.

(xiii) Now, the newly generated instance can be seen. Click on the instance, and you will get your instance’s summary. To connect the instance, click the “connect” button.

(xiv) Choose the SSH client option from the three options below. To connect to your Ubuntu server, you can copy and paste the command directly into your terminal. Mention in point 3 and, in the example, as in the image below.

Note: **To log in to your Ubuntu Server, please follow either STEP (xiv) or STEP 3. The command is the same in each of these steps.

STEP 3: Log in to your Ubuntu Server by executing the command mentioned below:

After logging in, install the necessary application software.

(i) Creation of SWAP Memory (You can leave this step, if you’re using 2GB or higher RAM. Since it is only necessary for the 1GB RAM.)

We create a shell file with the Nano Editor to configure the SWAP memory on the server.

After that, click Ctrl+x to save the file and validate the changes by pressing Y and then click Enter.

Now, apart from the aforementioned, execute the below two commands:

Well, by using below command, you can check the SWAP memory.

(ii) Install Apache2, MY SQL, PHP 7.4, and its modules

Apache, Php, and Mysql database are needed for the magneto backend. All three applications can be configured with these commands.

Check the version of PHP, if it is php7.4., then allow the PHP-module apache and the rewrite-apache module.

(iii) Install the Composer

STEP 4: SSH User creation

Presently, we were in our server’s root user, but due to security issues, we do not keep our application code in the directories of the root user. So, we have to create another SSH user for this.

Create an SSH user who will be the owner of the application code. I create an SSH user with the name “magento.” You can pick any name you want.

Eventually, this prompts a password window where you can set the password. Also, the remaining fields can be left empty by simply pressing the enter key. Additionally, after creating a user, we will switch to a new user.

STEP 5: Download Magento 2 by using the composer:

To install magento2 with composer, first, create the Access keys of Magento marketplace. If you have an account on Magento Marketplace, simply sign in and generate the access keys. If you don’t have an account, create an account by registering yourself on marketplace.magento.com

For generating Access keys, login into Magento marketplace, and from the top right corner of the page where your user name is displayed, navigate to My profile > Marketplace > My products > Access Keys

After all, create a new pair of Access keys. You need to provide the public Key as a username and the Private Key as a password when prompt.

STEP 6: Apache configuration

However, to support the web pages we will configure apache. So, we need to switch again to the root user for configuring apache.

You will find the following lines as shown below, after executing the above command.

Besides that, change this to :

Save it, and exit after this.

Furthermore, configure the envvars file by executing the below command:

And find these lines :

Modify the apache SSH username by this way :

And configure file apache2.conf by the following command:

Although, you will find the block code as shown below:

Modify it to the following code:

<Directory /home/magento/magento2/>

Options FollowSymLinks

AllowOverride All

Require all granted


Save the file and exit it.

Meanwhile, make some changes to php.ini file

file_uploads = On
allow_url_fopen = On
short_open_tag = On
memory_limit = 256M
upload_max_filesize = 100M
max_execution_time = 360
date.timezone = America/Chicago

Save and exit, php.ini file and then run the command below:

STEP 7: Install MYSQL Server for database creation by executing the following commands and when a password is asked after the below two commands, simply press ENTER
STEP 8: Similarly, Install the Elastic Search to move further
STEP 9: Likewise, execute the commands below to install Magento 2 by using the required variables such as host, database name, username, and password, etc.

when this command is successfully executed, the output will be identical as seen in the image below:

STEP 10: In addition, Enable and restart Apache2, the Magento2, and rewrite the module

while the installation of Magento2 has been successfully completed, go to your browser and enter the IP address of your EC2 instance or domain name. As a result, the homepage of your default eCommerce website will be like this:

STEP 11: Magento configuration

After all the above steps, you can now access your admin panel by using your credentials. Therefore, the admin login will open as in the image below.

You can’t log in to Magento Admin Panel after installation since two-factor authentication has been implemented in Magento2.4 and won’t be allowed you to log in. Hence, a page similar to the one below will open.

Moreover, to log in, you need a working email id. And then Magento sends an email to conduct the authentication on the given email id. In that case, the 2-factor authentication module must need to be disabled and later set up by the admin panel. Thus, we can disable 2FA by using the below command in the Magento web root directory:

php bin/magento module:disable Magento_TwoFactorAuth

**We highly recommend you to continue with 2-factor authentication**

At last, the admin panel is accessible. In addition, this is what the default admin dashboard looks like.

In short, your eCommerce platform is ready to use.

Thanks For Reading!

At last, we hope it works for you! And during this blog, you have found something valuable.

Keep in touch!!

In case of any help or query, please contact us or raise a ticket.

Category(s) AWS magento
. . .

Comments (4)

Add Your Comment

  • Tahir
    Fantastic article. Thank you!

    I followed the articles and ended with a clean install but after finishing when I try to login to MySQL as root user it asks me password, I simply hit enter that shows error. What is root password and how can I change it?

  • Roiman Cardenas
    You’re my hero! Thanks a lot!
    • Bhawana Dehran
      Thank you for your comment. Please check out our other interesting blogs available at https://cloudkul.com/blog/
  • css.php