How to Install Magento on Ubuntu 20.04

Install Magento on Ubuntu 20.04

In this article, we will have explained the necessary steps to install and configure Magento on Ubuntu 20.04 LTS. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Magento is without doubt one of the leading open-source eCommerce systems available, as a result of its customization and flexibility. It is created using the Zend Framework and makes use of MySQL as its database management system. Magento provides online retailers with an exceptionally flexible buying cart and it comes with a prosperous set of features, making it a very good selection for enterprises looking to have a web stop installed devoid of hassle.

Install Magento on Ubuntu 20.04

Step 1. First, before you start installing any package on your Ubuntu server, we always recommend making sure that all system packages are updated.

sudo apt update
sudo apt upgrade

Step 2. Install LAMP Stack on Ubuntu.

Magento is built with PHP. You can host it like you would any other web app is written in PHP. So, you’re going to need to set Ubuntu up as either a LAMP server. If you haven’t done so already, use our traditional LAMP guide to set up Ubuntu to serve PHP before you continue.

Step 3. Download and Install Magento on the Ubuntu system.

We are downloading the latest version of Magento from the official page, You have to create an account on the Magento site to download Magento. So, the following screen will appear before download. Create an account or log in to your existing account to start the download process.

cd Downloads
mkdir /var/www/html/magento
cp Magento-CE-2.4.1-2020-01-07-02-12-12.tar.gz /var/www/html/magento

Go to the Magento folder and unzip the Magento installer:

cd /var/www/html/magento
tar xzvf Magento-CE-2.4.1-2020-01-07-02-12-12.tar.gz /var/www/html/magento

Step 4. Creating a MySQL database for Magento.

Magento uses the MySQL database to store all its data like posts, pages, users, plugins, and themes settings. Log in to your MySQL server with the following command and enter your MySQL root password:

mysql -u root -p

Once you’re in the MySQL console, create a new database:

mysql> CREATE USER 'magento'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your-passwd';
mysql> create database magentodb;
mysql> GRANT ALL PRIVILEGES ON magentodb.* TO 'magento'@'localhost';
mysql> flush privileges;
mysql> quit

Next, run the following commands to set the necessary permissions for the Magento folder and restart the apache server:

sudo chown -R www-data:www-data /var/www/html/magento
sudo chmod -R /var/www/html/magento
sudo service apache2 restart

Step 5. Completing the Magento Installation.

In the last step of this guide, we need to access the Magento Web Interface and finish the installation. To finish the installation, open your browser and navigate to:


That’s all you need to do to install Magento on Ubuntu 20.04 LTS Focal Fossa. I hope you find this quick tip helpful. For further reading on the Magento open-source eCommerce platforms, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.