How to Install Latest Magento CMS in Ubuntu and Debian

Magento is a free, open-source CMS for web-commerce websites, first launched in 2008 and later acquired by eBay, according to W3Techs, Magento is used by 2.6% in all websites world-wide on the Internet, which is why it is important for a Linux admin to know how to install it on Linux machine which we will be explaining in this article.

Magento Features

  1. Free and open-sourced.
  2. Built using PHP, Zend framework and MySQL database.
  3. Can easily be used to create online web-stores.
  4. Ability to install & change default website theme, without need to change the content.
  5. Ability to install & configure modules to add more functionality.
  6. 3 Available editions to use which are: Community Edition – Professional Edition – Enterprise Edition.
  7. Supported by a large community.


This article will guide you to install the most recent version of “Community Edition” of Magento on a system running:

  1. Apache version 2.2 or 2.4
  2. PHP version 5.6 or 7.0.x or later with required extensions
  3. MySQL version 5.6 or later

Step 1: Install Apache, PHP and MySQL

1. Magento is a PHP script, that uses MySQL database, thats why we will need a running web-server and a MySQL database server with PHP Support, to install those things on Ubuntu/Debian, you will have to run the following commands in the terminal.

Note: On Ubuntu/Debian, during mysql installation, it will prompt you to setup password for mysql user (i.e. root) by default.

$ apt-get update && apt-get upgrade
$ sudo apt-get install php7.0-common php7.0-gd php7.0-mcrypt php7.0-curl php7.0-intl php7.0-xsl php7.0-mbstring php7.0-zip php7.0-iconv mysql-client mysql-server

Note: Currently, PHP 7.1.3 is the latest and most stable available version from the default Ubuntu and Debian repository, and works with Magento Community Edition 2.1 and 2.0.

If you’re using older Ubuntu or Debian distribution, consider upgrading to PHP 7.0 or later to adopt the new features of Magento CE (Community Edition).

$ sudo apt-get -y update
$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt-get -y update
$ sudo apt-get install -y php7.0 libapache2-mod-php7.0 php7.0 php7.0-common php7.0-gd php7.0-mysql php7.0-mcrypt php7.0-curl php7.0-intl php7.0-xsl php7.0-mbstring php7.0-zip php7.0-bcmath php7.0-iconv

2.Next, you need to increase PHP memory for Magento, to do this, open php.ini file.

$ sudo nano /etc/php/7.0/apache2/php.ini

Seach for the line ‘memory_limit‘ in the file.

memory_limit = 128M

And change the value to 512.

memory_limit = 512M

Once all the required packages has been installed on the system/server successful, now move forward to create a new MySQL database for Magento installation.

Step 2: Create MySQL Database for Magento

3. This section instructs, how to create a new database and new user for Magento. Although a new magento database is recommended, but optionally you can also deploy into an existing database, it’s upto you.

To create a new database and a user, login to your database server using root account and password that you’ve created during mysql-server installation above.

$ mysql -u root -p
## Creating New User for Magento Database ##
mysql> CREATE USER magento@localhost IDENTIFIED BY "your_password_here";

## Create New Database ##
mysql> create database magento;

## Grant Privileges to Database ##
mysql> GRANT ALL ON magento.* TO magento@localhost;

## FLUSH privileges ##

## Exit ##
mysql> exit

Step 3: Configure Apache for Magento

4. Now we will create a new virtual host file for our Magento site under /etc/apache2/sites-available/.

$ sudo nano /etc/apache2/sites-available/

Now add the following lines to it.

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /var/www/html/

    ErrorLog /var/www/html/
    CustomLog /var/www/html/ combined

    <Directory /var/www/html/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All


Save and close the file.

5. Now, enable new virtual host ( and ‘mod_rewrite‘ module.

$ sudo a2ensite
$ sudo a2enmod rewrite

6. We will disable the default virtual host configuration file to avoid any conflict with our new virtual host.

$ sudo a2dissite 000-default.conf

7. Finally, restart the Apache service.

$ sudo service apache2 restart

Step 4: Download Magento Community Edition

8. As usual, we’ll download the latest version from the official website, at the time of writing this article, the latest version from the Community Edition is 2.1.5, which you can download using the following link, it is under the “Full Release” section, of course, you need to register first before downloading Magento.


9. After you download Magento you may extract the downloaded file, place its content in /var/www/html/ using root permissions.

$ sudo mv Magento-CE-2.1.5-2017-02-20-05-36-16.tar.gz /var/www/html/
$ sudo tar -xvf Magento-CE-2.1.5-2017-02-20-05-36-16.tar.gz
$ sudo rm -rf Magento-CE-2.1.5-2017-02-20-05-36-16.tar.gz

10. Now we need to set Apache ownership to the files and folders.

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

11. Now open your browser and navigate to the following url, you will be presented with the Magento installation wizard.


Step 5: Install Magento Community Edition

12. This will be the first step you see in the installation process of Magento, Accept the license agreement and click “Continue”.

Magento Installation Wizard

Magento Installation Wizard

13. Next, the wizard will perform a Readiness Check for the correct PHP version, PHP extensions, file permissions and compatibility.

Magento Readiness Check

Magento Readiness Check

Magento Readiness Check Summary

Magento Readiness Check Summary

14. Enter magento database settings.

Magento Database Settings

Magento Database Settings

16. Magento Web site configuration.

Magento Web Configuration

Magento Web Configuration

17. Customize your Magento store by setting timezone, currency and language.

Customize Magento Store

Customize Magento Store

18. Create a new Admin account to manage your Magento store.

Create Magento Admin Account

Create Magento Admin Account

19. Now click ‘Install Now‘ to continue Magento installation.

Install Magento

Install Magento

Magento Installation Completes

Magento Installation Completes

Step 6: Magento Configuration

Magento is a very configurable CMS, the problem is that it isn’t easy, it is not like configuring WordPress or Drupal themes & modules, thats why we won’t talk a lot in this section here, however you may download Magento official user guide which will explain how to configure Magento from Bennington to advance for you.

  1. Magento Homepage
  2. Magento Documentaion

Have you ever tried Magento before? What do you think about it in comparing with other web-commerce CMSs? Please share your feedback using our comment section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Ravi Saive

I am Ravi Saive, creator of TecMint. A Computer Geek and Linux Guru who loves to share tricks and tips on Internet. Most Of My Servers runs on Open Source Platform called Linux. Follow Me: Twitter, Facebook and Google+

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide
The Complete Linux System Administrator Bundle
Become an Ethical Hacker Bonus Bundle

You may also like...

12 Responses

  1. Abota says:

    Thank you very much.

    I spent a week to install on the VPS without success. But, when reading your guide, I finished in just 10 minutes.

  2. Tarun says:

    Nice post although command line installation is much more faster and customisable.
    And there is a request can you make a post on magento migration from one domain to another.
    With all its components and data.

  3. charley says:

    Hello, If you go to you’ll see Welcome to Magento’s Installation Wizard! You can tick “I agree to the above terms and conditions.” But when you click the Continue button nothing happens, it’s as if the window freezes. The host is a Linux server with PHP Version 5.4.36, Apache Version 2.2.29, MySQL Version 5.5.40-cll Any thoughts? I’ve contacted the people controlling the server but they have not responded as yet.

    • Ravi Saive says:


      I just tried the installation wizard and it moves to the next step, now I am at Database Configuratin wizard..I think you should try on different browser…

  4. mohamed says:

    I followed that post but I faced many many problems while working o ubuntu 14.4
    there is many issues appeared to me

    • Ravi Saive says:

      Sorry for the trouble, actually the article is little outdated and haven’t updated since last one year. We are in process to update all our updated articles to latest version..give us patience and stay tuned…

  5. Tyler Sharp says:

    The only issues I had with this guide were:

    1.the location of the apache config

    “$ sudo nano /etc/apache2/sites-available/default”

    was not found. I found the file at

    “$sudo nano /etc/apache2/sites-available/000-default.conf”.

    The Directory section did not exist at all for me, I inserted it below the “documentroot” line (not 100% sure this is the correct location).

    2.The other issue is in the Magento configuration. It comes directly after fixing the write permissions. I am getting an error “php extension mcrypt must be loaded”. I fixed this by:

    “sudo php5enmod mcrypt”

    “sudo service apache2 reload”

    “sudo service apache2 restart”

  6. Nick says:

    HHHmm Not sure about those 777 permissions? Is there a way to not have to do that?

  7. jpadilla says:

    Hi, magento is rewritable for this reason your files should have permissions 777 and owned by the user the web public domain, not the user ROOT as this would generate update problems, editing and viewing the frontend

Leave a Reply to Abota Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.