Magento is a popular open source e-commerce platform written in PHP. Magento is highly popular ecommerce platform and it is owned and managed by Adobe Inc. The platform is flexible and has a large variety of features to build an online store. The latest version as of this writing is Magento 2.4.4 and it was released in April 12, 2022.
In this tutorial we will guide you on how to install Magento 2.4.4 community edition with the LAMP stack on Ubuntu 22.04.
Let us proceed with the installation.
At least 2 GB of RAM or Higher
2 Updating the system
sudo apt update -y && apt upgrade -y
3 Installing PHP and PHP extensions
The default PHP version ships for Ubuntu 22.04 is PHP 8.1. And PHP 8.1 is the required PHP version to run Magento 2.4.4. Now let us install PHP and it’s dependencies.
The database version required for Magento 2.4.4 is MySQL 8 or MariaDB 10.4. In this tutorial we will use MySQL as our database.
Let us install MySQL.
sudo apt install mysql-server
Let us configure MySQL server. But before we run the mysql_secure_installation let us first set the MySQL root password.
Let us set the MySQL root password.
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by 'mysecretpassword';
Then exit in the MySQL terminal.
If you don’t set the MySQL root password first before running mysql_secure_installation you will encounter this error:
… Failed! Error: SET PASSWORD has no significance for user ‘root’@’localhost’ as the authentication method used doesn’t store authentication data in the MySQL server. Please consider using ALTER USER instead if you want to change authentication parameters.
Let us proceed configuring MySQL.
Securing the MySQL server deployment.
Enter password for user root:
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
Using existing password for root.
Estimated strength of the password: 50
Change the password for root ? ((Press y|Y for Yes, any other key for No) : N
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
- Dropping test database...
- Removing privileges on test database...
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y
Restart MySQL service.
sudo systemctl restart mysql
Let us create a database for our Magento instance.
First login to MySQL console.
sudo mysql -u root -p
Then enter the root password you set while configuring MySQL.
Now let us create a database for our Magento instance. In the MySQL console run these commands.
Before we proceed in creating the database let us first change the password policy to “LOW” this is optional if you don’t want to use the strict password policy. To set the password policy to low run this command.
SET GLOBAL validate_password.policy = 0;
Let us create the database for our Magento instance.
create database magento2;
Let us create a database user.
CREATE USER 'magento_user'@'localhost' IDENTIFIED BY 'mypassword';
Grant all privileges to the newly created user to magento2 database.
GRANT ALL ON magento2.* TO 'magento_user'@'localhost';
Please don’t forget to change the “mypassword” to your desired password you can also change the database user “magento_user“ to your desired database user.
5 Web server Installation and Configuration
Since the stack that we are going to use in this tutorial is LAMP we will install Apache as our web server.