Install Magento 2 on Ubuntu

E-commerce websites provide a platform for buyers and sellers and make online business easier than before. Ecommerce site can be developed with a variety of different types of web applications. Magento is a popular open source CMS to develop e-commerce website with numerous functionalities, security and minimum programming knowledge. This CMS is supported running on both Windows and Linux. How Magento 2.2.6 can be installed on Ubuntu is shown in this tutorial.

Before Installation

You have to update the system and confirm that the following packages are installed and working properly before starting Magento Installation steps.

  • Apache2
  • MySQL 5.6+ or MariaDB
  • PHP 7+

Run the following commands to update and check your system is ready to start the installation.

$ sudo apt-get update
$ Apache2
$ PHP –v
$ mysql

If the following output appears then Apache, PHP and MySQL are installed.

Magento Installation Steps

Step-1: Download Magento Installer

Go to the following URL address, select the latest version of Magento and click on DOWNLOAD button. Here ‘Magento Open Source 2.2.6 tar.gz’ is selected and downloaded.

You have to create an account in Magento site to download Magento. So, the following screen will appear before download. Create an account or login to your existing account to start the download process.

Step-2: Create folder and unzip Magento installer

By default, Magento will be downloaded on Downloads folder. Run the commands to create a folder named ‘magento’ under /var/www/html folder and copy the downloaded Magento file on that folder.

$ cd Downloads
$ ls
$ mkdir /var/www/html/magento
$ cp Magento-CE-2.2.6-2018-09-07-02-1238.tar.gz  /var/www/html/magento

Go to magento folder and unzip Magento installer.

$ cd /var/www/html/magento
$ ls
$ tar xzvf Magento-CE-2.2.6-2018-09-07-02-1238.tar.gz  /var/www/html/magento

Step-3: PHP Settings

You have to set permission to edit and save php.ini file.

chmod 777 /etc/php/7.1/apache2/php.ini

Open php.ini file from the location /etc/php/7.1/apache2/ and increase the memory limit and enable the following extensions.

Step-4: Database Setting

Login to MySQL server.

$ sudo mysql –u root -p

Create a database, ‘magento’.

mysql>create database magento;

Step-5: Setting Necessary Permissions

Run the following commands to set the necessary permissions for 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-6: Setup Magento

Open a browser and enter the following URL and click on Agree and Setup Magento button.


If any necessary PHP extension is missing then it will be displayed in this page. Here, two extension are missing or not working, soap and bcmath.

Install the missing extensions.

$ sudo apt-get install php-soap
sudo apt-get install php7.1-bcmath

Again run the setup. If everything is ok then click on Next button. Fill up the following form with database hostname, username, password and database name. Click on Next button.

Set the base URL of the store and admin in this step. Here, I have removed admin prefix for easy access.

Next step is for customizing the store. Keep default settings and click on Next.

Create admin account to login to the dashboard of admin panel and click Next.

Click on Install Now button after completing all setup.

If the installation completes successfully then the following screen will appear.

Step-7: Verify Magento is working or not

Run the following URL from the browser to test the store view is working or not.


Run the following URL to login to Admin Panel. Provide the valid username and password that you have created in previous step.


The following admin panel will appear if Magento is installed and working properly.

Hope, this tutorial will help you to learn and use Magento on Ubuntu.

Sandclock IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, Sandclock IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

How to upgrade the kernel on Ubuntu 17.10

Ubuntu 17.10 Artful Aardvark uses kernel 4.13.0 by default. It is pretty new. Most of the people will not need to update...

How to Keep Ubuntu 17.10 up to Date

When you install Ubuntu from a ISO image, the operating system is not up to date. Because the ISO is not updated on the official...

7 Best Terminal Alternatives for Ubuntu

Many people using Linux are doing so for application programming, system administration and other command line tasks. When...
Bài Viết

Bài Viết Mới Cập Nhật

Hướng dẫn chuyển đổi windows server windows evaluation to standard và active windows server 2008 + 2012 + 2016 + 2019

How to Update Ubuntu Linux

Squid Proxy Manager cài đặt và quản lý Proxy Squid tự động trên ubuntu

Hướng dẫn cài đặt Apache CloudStack

Hướng dẫn ký file PDF bằng chữ ký số (chữ ký điện tử) và sửa lỗi mới nhất 2021 foxit reader