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:
- $ 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
- $ sudo a2enmod rewrite
b) After successfully installation of these packages, make changes in the apache2.conf file and AllowOverride all for Directory permission.
- $ cd /etc/apache
- $ 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:
- $ sudo systemctl restart apache2.service
d) Next step to install Magento 2 in var/www/html document using these commands:
- cd /var/ww/html/
- git clone https://github.com/magento/magento2.git
- cd magento2
- 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-
- $ Sudo apt-get install php-exnteionname (like php-gd)
After installing all missing PHP extensions, change current directory to Magento 2 and install composer:
- $ cd /var/www/html/magento2
- $ 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.
g) Next step is to change directories permission to
- $ sudo chmod -R 777 /var/www/html/magento2/
- $ sudo chmod -R 777 /var/www/html/magento2/var/
- $ 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:
- $ sudo mysql –u magento2 -p
Enter password magento2 and use sql query:
- 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/
If you face any permission issue, grant permission to Magento 2 root directory-
- $ 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!