Learn Magento 2.4.6 Installation On Ubuntu 22.04

Learn Magento 2.4.6 Installation On Ubuntu 22.04

What’s The Magento, Exactly?

Magento is an open-source eCommerce platform that provides online shoppers with a versatile shopping cart interface. 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.

Installation Requirements For Magento 2.4.6:

Operating systems (Linux x86-64)

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

Memory requirement

  • Magento 2.4.6 requires 4 GB or higher RAM.

Composer

  • Composer 2.2.x

Web servers

  • Apache 2.4

  • Nginx 1.x

Database

  • MySQL 8.0

  • MariaDB 10.6

PHP

Magento 2.4.0 supports PHP 7.4

Magento 2.4.6 supports PHP 8.1

Elasticsearch

  • Elasticsearch 7.17

  • 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: devdocs.magento.com/guides/v2.4/install-gde..

What We’re Going To Use:

  • OS: Ubuntu 22.04

  • SERVER: Apache 2

  • RAM: 4 GB

  • PHP: 8.1

  • MY SQL: 8.0

  • Composer: 2.2.x

  • Elasticsearch: 7.17

Magento 2.4.6 Installation

So let’s move to the installation part.

STEP 1: Log in to your Ubuntu Server

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

chmod 400 /path to .pem file

STEP 2: Install Apache2, PHP , and its modules

Apache, PHP, and its module are needed for the Magneto backend. Use below mentioned commands to install the packages.

sudo apt update

Check the version of PHP, then allow the PHP-module apache and the rewrite-apache module.

php -v

STEP 3: Install the Composer

sudo apt install 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 created an SSH user with the name “magento.” You can pick any name you want.

sudo adduser magento

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.4.6 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

To generate Access keys, log in to Magento marketplace, and from the top right corner of the page where your user name is displayed, navigate toMy 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 prompted.

cd /home/magento

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.

sudo nano /etc/apache2/sites-enabled/000-default.conf

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

Besides that, change this to :

ServerAdmin webmaster@localhost
DocumentRoot /home/magento/magento2
ServerName localhost

We are using localhost but you can define your domain name

Save it, and exit after this.

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

sudo nano /etc/apache2/envvars

And find these lines :

Modify the Apache SSH username in this way :

export APACHE_RUN_USER=magento
export APACHE_RUN_GROUP=magento

And configure file apache2.conf by the following command:

sudo nano /etc/apache2/apache2.conf

Although, you will find the block code shown below:

Modify it to the following code:

<Directory /home/magento/magento2/>

Options FollowSymLinks

AllowOverride All

Require all granted

</Directory>

Save the file then exit it, and run the below command to check if any issues –

#apache2ctl -t

#systemctl restart apache2

Meanwhile, make some changes to the php.ini file

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

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, the php.ini file, and then run the command below:

sudo service apache2 restart

STEP 7: Install MySql server

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

sudo apt-get install mysql-server

Similarly, Install the Elastic Search to move further

apt-get install apt-transport-https

After the installation of Elasticsearch, define the memory for Elasticsearch

vim /etc/elasticsearch/jvm.options.d/custom.options
-Xms1g
-Xmx1g

1

service elasticsearch start

STEP 9: Install Magento 2.4.6

Likewise, execute the commands below to install Magento 2 by using the required variables such as host, database name, username, password, etc.

cd /home/magento/magento2

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

sudo service apache2 restart

STEP 10: Enable the rewrite module, give the permission and restart the apache2 service

sudo a2enmod rewrite

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 following 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 find admin login details in env.phpfile

#cat /home/magento/magento2/app/etc/env.php

Then you can login to – yourdomain/admin_5gxvjf

You can’t log in to the Magento Admin Panel after installation since two-factor authentication has been implemented in Magento 2.4.6.

Hence, a page similar to the one below will open.

Moreover, to log in, you need a working email id. Then Magento sends an email to authenticate the given email ID.

In order to log in to your Magento panel, the default flow is to first disable the 2-factor authentication and later on setting up it again.

Thus, we can disable 2FA by using the below command in the Magento web root directory:

1

#php bin/magento module:disable Magento_AdminAdobeImsTwoFactorAuth

We highly recommend you 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 Magento 2.4.6 e-commerce 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!!