Back to Blog

Installation of Magento 2 on Ubuntu 16.04 LTS

Installation of Magento 2 on Ubuntu 16.04 LTS – I am writing this article for absolute beginner with deeper explanation of all steps which are required to install and configure Magento 2.0 on Ubuntu OS.
Let’s start:
a) Install Apache2, PHP, MySQL Server, composer and required packages for Magento 2.0.       Using command:

  1. $ sudo apt-get install apache2 php libapache2-mod-php mysql-server php-mysql php- dom php-simplexml php-curl php-intl php-xsl php-mbstring php-zip php-xml composer
  1. $ sudo a2enmod rewrite

b) After successfully installation of these packages, make changes in the apache2.conf file     and AllowOverride all for Directory permission.

  1. $ cd /etc/apache
  2. $ Sudo nano apache2.conf

Changes from

Options Indexes FollowSymLinks
AllowOverride none
Require all granted

To

Options Indexes FollowSymLinks
AllowOverride all
Require all granted

c) Use ^x (Ctrl + X) to exit from edit file screen. After making change in Config file, you need     to restart Apache. Use this command:

  1. $ sudo systemctl restart apache2.service

d) Next step to install Magento 2 in var/www/html document using these commands:

  1. cd /var/ww/html/
  2. git clone https://github.com/magento/magento2.git
  3. cd magento2
  4. composer install

e) You might face problem while installing Composer in Magneto 2 directory, like some of          PHP extensions are missing. Don’t be panic in this case and install missing extensions.

Using commands like-

  1. $ Sudo apt-get install php-exnteionname (like php-gd)

After installing all missing PHP extensions, change current directory to Magento 2 and            install composer:

  1. $ cd /var/www/html/magento2
  2. $ composer install

f) Following messages come on screen:
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file

– Installing magento/magento-composer-installer (0.1.6)
Downloading: 100%

– Installing braintree/braintree_php (2.39.0)
Downloading: 100%

– Installing justinrainbow/json-schema (1.6.1)
Downloading: 100%

– Installing symfony/console (v2.6.13)
Downloading: 100%

– Installing symfony/process (v2.8.4)
Downloading: 100%

………………………………………………………………………………………….
………………………………………………………………………………………….

– Installing composer/composer (1.0.0-alpha10)
Downloading: 100%

– Installing magento/composer (1.0.2)
Authentication required (repo.magento.com):

Username:
Password:

  If composer prompts for authentication.

  Login to Login here https://www.magentocommerce.com/ and use public key as    Username and private key as Password.

Installation of Magento 2 on Ubuntu 16.04 LTS

g) Next step is to change directories permission to

  1. $ sudo chmod -R 777 /var/www/html/magento2/
  2. $ sudo chmod -R 777 /var/www/html/magento2/var/
  3. $ sudo chmod -R 777 /var/www/html/magento2/pub/

Now we move to Mysql. To create Mysql database for magento 2 installation.

Use Following command:
$ sudo mysql –u root -p
Enter Sudo password and now you are ready to execute Sql queries using mysql prompt.      Enter the following commands in the order to create a database instance named     magento2 with user name magento2
h) Create database magento2;
GRANT ALL ON magento.* TO magento2@localhost IDENTIFIED BY ‘magento2’;
Database magento2 is created and all permissions are granted to magent2@localhost         user with password magento2.
To check you can use:

  1. $ sudo mysql –u magento2 -p

Enter password magento2 and use sql query:

  1. Mysql > show database;

Use exit to come out from mysql prompt.

Now you are ready for final step to install magento2.

    Open http://localhost/magento2/setup/

Magento Installation

If you face any permission issue, grant permission to Magento 2 root directory-

  1. $ sudo chmod -R 777 /var/www/html/magento2/

When you get green check for file permission check, click next till installation finish.
You can browse magento 2 using
     http://localhost/magento2/
     or
     http://{ipaddress}/magento2/

At this stage, we are completed with Magento 2 installation on Ubuntu 16.04 LTS. Hope it       helps you!

Back to Blog
top