Magento Tutorial – Part 2 – How to Install Magento 2

Magento Tutorial – Part 2 – How to Install Magento 2


Are you Beginner and want to learn something new!

You are at right place, You can learn magento from us and become Magento Developer.

So Let’s Start, In this video we are explaining the steps to install magento in ubuntu.

So First Before Start Magento Installation you should know What is Magento ?, You can visit our previous Video to know about magento.

You can also watch our video

English Version

Hindi Version

Step 1:

You need to make sure that your system has required things to install magento, Below are basic requirement to install magento in the system.

Requirement to install Magento – Web Server (Apache / Nginx) – Mysql – PHP – composer (If you are installing magento via composer)

Do below process to install web server and requirement things

Install Web server

First of all you need to run below command

sudo apt-get update -y

sudo apt-get upgrade -y

Install Apache 2.2 or 2.4 

sudo apt-get install apache2 -y

after installing apache you can the apache version by this command -:

sudo apache2 -v

Install MySQL 5.6 Or 5.7

sudo apt install mysql-server

after then run this command for mysql server configuration

sudo mysql_secure_installation

After it will prompt for VALIDATE_PASSWORD , you can set it or not, optional
After it, it will prompt for Root Password

Enter password

after Root PAssword, There will be few more prompts like “anonymous user”, “Disallow Root Login Remotely”, Remove Test Database”, “Reload Priviledges” etc.
It’s optional and depends on your choice.

Start MySQL Configuration 

After that, you need to create mysql user and database.
First, Run this command -:
GRANT ALL PRIVILEGES ON *.* TO ‘training’@’localhost’ IDENTIFIED BY         ‘your mysql password’;
Then we create a database.
Database user name :- training
Database Password :- password
Database Name :- magento

Install PHP 

sudo apt-get install php -y

you can also confirm the PHP version by this command -:
sudo php -v

Install PHP extensions required for Magento

Please run all these commands -:

sudo apt-get install php7.2-bcmath
sudo apt-get install php7.2-common
sudo apt-get install php7.2-mbstring
sudo apt-get install php7.2-xmlrpc
sudo apt-get install php7.2-soap
sudo apt-get install php7.2-gd
sudo apt-get install php7.2-xml
sudo apt-get install php7.2-intl
sudo apt-get install php7.2-mysql
sudo apt-get install php7.2-cli
sudo apt-get install php7.2-mcrypt
sudo apt-get install php7.2-ldap
sudo apt-get install php7.2-zip
sudo apt-get install php7.2-curl

Configuring Apache2 and Create Virtual Host

Create the configuration file phpacademy.local.conf (this can be any file name as per your choice) inside /etc/apache2/sites-available/
And paste this content according to your configuration in phpacademy.local.conf

<VirtualHost *:80>
DocumentRoot /var/www/html/phpacademy/
ServerName phpacademy.local
ServerAlias www.phpacademy.local
<Directory /var/www/html/phpacademy/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

Here phpacademy is the folder where u will install magento.

Your virtual host is configured, run the commands below to enable it:

sudo a2ensite phpacademy.local.conf
sudo a2enmod rewrite

after then you have to restart the Apache service to Apache2 allows all the settings changes to take effect.

sudo service apache2 restart

Now Install composer

Run below command to install composer bcz we will install magento using composer

– sudo apt-get update – sudo apt-get install curl – sudo curl -s | php – sudo mv composer.phar /usr/local/bin/composer

Download Magento via composer

composer create-project –repository-url= magento/project-community-edition directory-name

It will ask for magento authentication key So you need to login to magento and get the key as per below screenshot

paste it. as username and password , Public key is your username and private key is ur password.

It will ask for save the auth.json, So if you want to keep it generic for all magento installation so press Y if you dont want to save press n.

You can also save auth.json file under your project as well below is the content for auth.json

  "http-basic": {
    "": {
      "username": "0af185d6ad05cf64a3b3a29b8f",
      "password": "ca8b0e3b1e26308221f5b2"    }     

This file you can put in your /var/www/html/phpacademy/ folder as auth.json so whenever you will upgrade magento or extension it will not ask for the authentication key again.

Now give permission to directory

– cd /var/www/html/magento install directory – find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} + – find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} + – chown -R :www-data . # Ubuntu – chmod u+x bin/magento

Now you can install in 2 ways either via browser or via command here I am installing via command as it’s a quite fast process

php bin/magento setup:install \ –base-url=http://phpacademy.local \ –db-host=localhost \ –db-name=phpacademy \ –db-user=root \ –db-password=root@123 \ –admin-firstname=PHP \ –admin-lastname=Academy \ – \ –admin-user=admin \ –admin-password=admin123 \ –language=en_US \ –currency=USD \ –timezone=America/Chicago \ –use-rewrites=1

Here you have to define url and database name and admin details etc. and run this command. so it will install magento and provide admin uri.

Hope you understand the process and use it, Please keep visiting our blog as we are coming with more knowledge in magento.

If you are looking for job you can join us at where we are positing new jobs daily.

Leave a Reply
Your email address will not be published. *