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.

Requirements

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 ##
mysql> FLUSH PRIVILEGES;

## Exit ##
mysql> exit

Step 3: Configure Apache for Magento

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

$ sudo nano /etc/apache2/sites-available/example.com.conf

Now add the following lines to it.

<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.com
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/example.com/

    ErrorLog /var/www/html/example.com/logs/error.log
    CustomLog /var/www/html/example.com/logs/access.log combined

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

</VirtualHost>

Save and close the file.

5. Now, enable new virtual host (example.com.conf) and ‘mod_rewrite‘ module.

$ sudo a2ensite example.com.conf
$ 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.

  1. http://www.magentocommerce.com/download

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/example.com/
$ 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/example.com/

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

http://server_domain_name_or_IP/

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.

Ravi Saive
I am an experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

12 thoughts on “How to Install Latest Magento CMS in Ubuntu and Debian”

  1. 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.

    Reply
  2. 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.

    Reply
  3. Hello, If you go to weightlossn0w.com 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.

    Reply
    • @Charley,

      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…

      Reply
    • @Mohamed,
      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 some..be patience and stay tuned…

      Reply
  4. 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”

    Reply
  5. 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

    Reply

Got something to say? Join the discussion.

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.