How to Install Magento on Ubuntu

Magento is a powerful open-source e-commerce platform that enables businesses to create and manage their online stores efficiently. Its purpose is to provide a flexible and scalable solution for merchants to sell their products and services online. By using Magento, Ubuntu users can create a professional-looking online store with a wide range of features, including product management, order management, payment gateways, and shipping integrations. 

Magento also offers a high level of customization, allowing users to tailor their store to their specific needs. Additionally, Magento’s large community of developers and users ensures that there are plenty of resources available for troubleshooting and customization. Magento’s benefits include improved sales, increased customer engagement, and enhanced brand visibility. 

In this article, we will cover the step-by-step process of installing Ubuntu Magento setup, providing users with a comprehensive guide to getting started with this powerful e-commerce platform.

Prerequisites to Install Magento on Ubuntu

Before we dive into the installation process, make sure you have the following prerequisites met:

  1. Ubuntu Version: This guide is tested on Ubuntu 20.04 LTS (Focal Fossa) and Ubuntu 22.04 LTS (Jammy Jellyfish). However, the steps should work on other versions of Ubuntu as well.
  2. Server Requirements: You’ll need a server with a minimum of 2 GB RAM, 2 CPU cores, and 20 GB of free disk space.
  3. LAMP Stack: Magento requires a LAMP (Linux, Apache, MySQL, and PHP) stack to function. We’ll install these components during the process.
  4. Domain Name: You’ll need a domain name or a subdomain to access your Magento store.

Installing Magento on Ubuntu

Step 1: Install LAMP Stack

The LAMP stack is a set of software components that Magento relies on to function. Let’s install them one by one:

Install Apache

Apache is a popular web server software that serves web pages to visitors. To install Apache on Ubuntu, run the following command:

sudo apt update && sudo apt install apache2 -y
install-apache2

Once installed, start the Apache service and enable it to start automatically on boot:

sudo systemctl start apache2
sudo systemctl enable apache2
start-apache2

Step 2: Install MySQL

MySQL is a relational database management system that stores Magento’s data. To install MySQL, run the following command:

sudo apt install mysql-server
mysql-server

During the installation process, you’ll be prompted to set a password for the MySQL root user. Make sure to choose a strong password and remember it, as you’ll need it later.

Once installed, start the MySQL service and enable it to start automatically on boot:

sudo systemctl start mysql && sudo systemctl enable mysql

Step 3: Install PHP

PHP is a server-side scripting language that Magento uses to generate web pages. To install PHP, run the following command:

sudo apt install php libapache2-mod-php php-mysql php-curl php-gd php-dom php-xml
install-php

Once installed, restart the Apache service to apply the changes:

sudo systemctl restart apache2
sudo-restart

Install Additional PHP Modules

Magento requires some additional PHP modules to function properly. To install them, run the following command:

sudo apt install php-zip php-soap php-bcmath php-intl

Create a MySQL Database

Now that we have the LAMP stack installed, let’s create a MySQL database for Magento:

1. Log in to the MySQL shell using the root user and password.

sudo mysql -u root -p
sudo-mysql

Next, create a new database for Magento:

CREATE DATABASE magento;
database

After that create a new user and grant privileges to the database:

CREATE USER 'magento_user'@'%' IDENTIFIED BY 'strong_password';
GRANT ALL PRIVILEGES ON magento.* TO 'magento_user'@'%';
create-user

You need to replace `strong_password` with a strong password of your choice.

Lastly, exit the MySQL shell:

EXIT;
bye-exit

Download and Extract Magento

Now that we have the database set up, let’s download and extract the Magento files by visiting GitHub and then download either .zip file or tar.gz file:

magento-release

After that execute the below command to extract the content to the `/var/www/html` directory:

sudo tar -xvf ~/Downloads/magento2-2.4.7-p1.tar.gz -C /var/www/html
magento framework

Next, change the ownership of the Magento files to the Apache user:

sudo chown -R www-data:www-data /var/www/html
sudo-chown

Now that we have the Magento files extracted, let’s configure Apache to serve the Magento store:

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

Next, add the following content inside it:

<VirtualHost *:80>
ServerName example.com    
ServerAdmin [email protected]    
DocumentRoot /var/www/html    
<Directory /var/www/html>       
Options Indexes FollowSymLinks MultiViews        
AllowOverride All        
Require all granted    
</Directory>    
ErrorLog /var/log/apache2/magento_error.log    
CustomLog /var/log/apache2/magento_access.log combined 
</VirtualHost>
server-name

Replace example.com with your domain name and then save and close the file. Next, enable the new configuration file:

systemctl reload apache2
reload-apache2

Install Magento

Now that we have the Apache configuration in place, let’s install Magento Ubuntu:

Open a web browser and navigate to your domain name (e.g., http://example.com).

You should see the Magento installation wizard.

Follow the installation wizard to configure your Magento store:

  • Accept the terms and conditions.
  • Choose your language and currency.

Configure your database settings:

Host: localhost

Database name: magento

Username: magento_user

Password: strong_password

  • Configure your admin user:

Username: admin

Email: [email protected]

Password: strong_password

Click “Install” to begin the installation process.

magento-installer

This will take some time and after that, you can configure your online store by providing the credentials that you set earlier.

Conclusion

The installation process of Magento on Ubuntu is a straightforward process that requires careful planning and execution. By following the steps outlined in this article, users can successfully install and configure Magento on their Ubuntu system. Magento is a powerful e-commerce platform that offers a wide range of features and benefits, including scalability, flexibility, and customization. With its large community of developers and users, Magento is an ideal choice for businesses looking to create a professional-looking online store. 

By completing the installation process, users can begin configuring their online store, including setting up products, payment gateways, and shipping integrations. Magento’s features and benefits enable businesses to streamline their online operations, improve customer satisfaction, and increase revenue. With Magento, Ubuntu users can take their online business to the next level, providing a seamless and secure shopping experience for their customers.

Whether you’re an experienced developer or new to Linux, having a setup that meets your needs is essential. Ultahost provides a robust and reliable platform. with Linux VPS hosting providing dedicated resources to ensure the speed and stability necessary for efficient task handling.

FAQ

What are system requirements for installing Magento?
How do I install PHP and necessary extensions?
How do I install Composer?
How do I complete the Magento installation via the web browser?
What are some good resources for Magento support?

Related Post

How to Install Go on Ubuntu 22.04

Go, also known as Golang, is a modern programming langu...

How to Install Ansible on Ubuntu

Ansible, an open-source automation tool, simplifies inf...

How To Install Node.js on Ubuntu 22.04

Node.js is a runtime environment that enables the execu...

How to Install Steam in Linux for Gaming

Linux gaming is exploding in popularity, and Steam is l...

How to Check Linux Version

Linux is an open-source operating system that offers a ...

How to Check Ubuntu Version via Terminal and

Understanding your Ubuntu version is important for stay...

Leave a Comment