How to Magento 2.4 Installation On Ubuntu 20.04 with out any error

Installation Requirements For Magento 2.4:

Memory requirement

Magento2 requires 2GB or higher RAM. 


Composer 1.x supported by Magento.

Web servers



MySQL 8.0


Magento supports PHP 7.4.0


Magento supports Elasticsearch 7.x

Command through Installed Apache2, MY SQL, PHP 7.4, and its modules

sudo apt update
sudo apt install apache2 
sudo systemctl start apache2.service
sudo systemctl enable apache2.service
sudo apt-get install -y software-properties-common 
sudo add-apt-repository ppa:ondrej/php 
sudo apt-get update 
sudo apt install php7.4 libapache2-mod-php7.4 php7.4-common php7.4-gmp php7.4-curl php7.4-soap php7.4-bcmath php7.4-intl php7.4-mbstring php7.4-xmlrpc php7.4-mysql php7.4-gd php7.4-xml php7.4-cli php7.4-zip

Below check the php version. then allow the PHP-module apache rewrite apache module.
php -v
sudo a2enmod php7.4
sudo a2enmod rewrite
sudo service apache2 restart

Install the Composer

sudo apt install composer

Create SSH user name “magento.
sudo adduser magento

Download Magento 2 By Using The Composer:

To install magento2 composer first, After login in Magento marketplace and generate the access keys. create an account in marketplace.magento.com

For generating Access keys to login Magento marketplace

My profile > Marketplace > My products > Access Keys

cd /home/magento
sudo composer create-project --repository=https://repo.magento.com/ magento/project-community-edition magento2

Username : Public Key
Password : Private Key

Apache Configuration

 root user for configuring apache2 file

sudo nano /etc/apache2/sites-available/magento.conf

Add this code in magento.conf file.

<VirtualHost *:80>
    ServerAdmin admin@example.com
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /home/magento/magento2
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

<Directory /home/magento/magento2/>
Options FollowSymLinks
AllowOverride All
Require all granted

Also change in hosts file. your public ip and site name add in hosts file

sudo nano /etc/hosts

your public ip    example.com

After run this code.

sudo a2ensite magento.conf

Configure the envvars file in replace this two line.

sudo nano /etc/apache2/envvars
Modify the apache SSH username by this way :

Before :

export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data

After chanage :

export APACHE_RUN_USER=magento
export APACHE_RUN_GROUP=magento

Meanwhile, make some changes to php.ini file

sudo nano /etc/php/7.4/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, php.ini file and then run the command below:
sudo service apache2 restart 

Install MYSQL Server For Database Creation:

sudo apt-get install mysql-server
sudo mysql -u root -p
create database magento2;
CREATE USER 'magento2user'@'localhost' IDENTIFIED BY 'magento';
GRANT ALL ON magento2.* TO 'magento2user'@'localhost' WITH GRANT OPTION;
flush privileges;

Installed Elastic Search :

sudo su
apt-get install apt-transport-https
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | apt-key add -
echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | tee -a /etc/apt/sources.list.d/elastic-7.x.list
apt update &amp;&amp; apt-get install elasticsearch
service elasticsearch start
sysctl -w vm.max_map_count=262144
echo "vm.max_map_count=262144" | tee /etc/sysctl.d/elasticsearch.conf
service elasticsearch restart

After Execute Install Magento 2 Variables Such As Host, Database Name, Username, And Password, Etc.
cd /home/magento/magento2
sudo bin/magento setup:install --base-url=http:// Public IP Address or Domain Name --db-host=localhost --db-name=magento2 --db-user=magento2user --db-password=magento --admin-firstname=Admin --admin-lastname=User --admin-email=admin@example.com --admin-user=admin --admin-password=admin123 --language=en_US --currency=USD --timezone=America/Chicago --use-rewrites=1
sudo service apache2 restart

In Addition, Enable And Restart Apache2, The Magento2, And Rewrite The Module
sudo a2enmod rewrite 
sudo chmod -R 755 /home/magento/magento2
sudo chown -R magento:magento /home/magento/magento2
sudo systemctl restart apache2.service

while the installation of Magento2 has been successfully completed.



Admin pannel in login :

http://yourdomain.com/Magento Admin URI
admin page

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

php bin/magento module:disable Magento_TwoFactorAuth


Post a Comment