Installing Magento eCommerce Site on Ubuntu 22.04 LTS

Introdcution

Magento is an open-source e-commerce platform written in PHP. It was first released in 2008 and has since become one of the most popular e-commerce platforms available.

Prerequisites

You must following things to complete this tutorial.

  • Ubuntu 22.04 LTS up and running.
  • Basic knowledge of Linux commands.
  • Root permission.
  • Internet connectivity.

Step 1: Update Ubuntu System

Update your Ubuntu system by running the following command:

sudo apt-get update
sudo apt-get upgrade

Step 2: Installing Dependencies

Magento required few of the PHP modules to run, Use the given command for the same.

Install the required dependencies for Magento:

sudo apt-get install apache2 mariadb-server php libapache2-mod-php php-mysql php-curl php-gd php-mbstring php-intl php-xml php-zip unzip
 -y

Step 3: Creating Magento Database

We need to create the database, user and permission for magento, Use the given command for the same.

Create a new database and user for Magento:

sudo mysql -u root -p

To create database, User and permission.

CREATE DATABASE magento;
GRANT ALL PRIVILEGES ON magento.* TO 'magento_user'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
exit;

Note: Replace ‘magento_user’ and ‘password’ with your desired values.

Step 4: Downloading Magento

We need to download Magento’s zip file, Use the given command for the same.

Download the latest version of Magento from the official website:

wget https://magento.com/tech-resources/download?file=Magento_Community_Edition_2.4.3-p1_2022-02-24_03-35-16.zip

Step 5: Extracting Magento Zip

Extract the downloaded file and move it to the web directory:

unzip Magento_Community_Edition_2.4.3-p1_2022-02-24_03-35-16.zip
sudo mv magento /var/www/html/

Step 6: Updating Permission

Set the correct permissions for the Magento directory:

sudo chown -R www-data:www-data /var/www/html/magento/
sudo chmod -R 755 /var/www/html/magento/

Step 7: Creating Virtualhost

We need to create a virtual host which will be connect with our domain name, Use the given command for the same.

Configure Apache to serve Magento:

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

Add the following content to the file:

<VirtualHost *:80>
    ServerAdmin admin@example.com
    DocumentRoot /var/www/html/magento/
    ServerName example.com
    ServerAlias www.example.com
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    <Directory "/var/www/html/magento/">
        AllowOverride all
    </Directory>
</VirtualHost>

Note: Replace ‘example.com’ with your domain name or IP address.

Step 8: Enabling Magento Site

To get new change we need to enable magento virtual host config and restart the apache web server once, To do that use the following command.

Enable the Magento site and restart Apache:

sudo a2ensite magento.conf
sudo systemctl restart apache2

Step 9: Access Magento

Access Magento in your web browser by visiting your server’s domain name or IP address. Follow the installation wizard to complete the setup.

Conclusion

We have successfully installed and setup the Magento using the LAMP stack on Ubuntu. If you have any questions or issues, please leave a comment below.

Installing Magento eCommerce Site on Ubuntu 22.04 LTS

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top