Installing and configuring Magento 2.3 on Ubuntu

Posted By :Harsh Soni |31st January 2019
Installing and configuring Magento 2.3 on Ubuntu 16.04

Magento is an Open Source PHP based CMS or an e-commerce platform for small businesses. There are different editions of this platform where the free open source edition comes with the features to meet basic requirements. It is a perfect platform for developers as well as for small business sites or anyone who wants to creates its own store in a minimal span of time.

 

Here we are going to configure Magento 2 on our localhost using Composer(which is the easiest way). I am configuring this setup on ubuntu 16.04. We need a basic web server functionality to provide web service like Apache2 or Nginx, a database such as MySQL or MariaDB and PHP v7.1+, or in other words, you need a LAMP stack installed in your system.

 

Installation Prerequisites

 

  1. Apache2
  2. MySQL/MariaDB
  3. Composer
  4. PHP

Assuming that you are starting from scratch, we will start by installing apache2

 

sudo apt update
sudo apt-get install apache2 -y

 

Once done you can verify by this code

 

apache2 -v

Note:- Make sure to enable rewrite mode to Magento2 work properly 

 

sudo a2enmod rewrite

 

To test Apache2 is installed and working, open your browser and browse to the server hostname or IP address you will see a page similar to this which indicates that you have installed the apache2 successfully.

 

 

Now we need a database to interact with our application and we are using MariaDB which is an open source Database server and can be used with Magento

 

sudo apt-get install mariadb-server mariadb-client

 

We need to secure our MariaDB server from remote access by running the following command

 

sudo mysql_secure_installation

 

When prompted, answer the questions below by following the guide.

 

=> Enter current password for root (enter for none): Just press the Enter

=> Set root password? [Y/n]: Y

=> New password: Enter password

=> Re-enter new password: Repeat password

=> Remove anonymous users? [Y/n]: Y

=> Disallow root login remotely? [Y/n]: Y

=> Remove test database and access to it? [Y/n]:  Y

=> Reload privilege tables now? [Y/n]:  Y

=> Restart MariaDB server 

 

To test it is successfully installed run the following command and you will see a welcome message.

 

sudo mysql -u root -p

 

Magento2 supports PHP 7.1 or higher and we need to install/upgrade it for Magento2 to work properly, PHP 7.1 is not available on Ubuntu repositories and will get it from a third-party repository.

 

Run the commands below to add the below third party repository and download PHP

 

sudo apt-get install software-properties-common

sudo add-apt-repository ppa:ondrej/php

 

Next, Run this command to install the PHP related modules which are necessary for Magento2

 

sudo apt install php7.1 libapache2-mod-php7.1 php7.1-common php7.1-gmp php7.1-curl php7.1-soap php7.1-bcmath php7.1-intl php7.1-mbstring php7.1-xmlrpc php7.1-mcrypt php7.1-mysql php7.1-gd php7.1-xml php7.1-cli php7.1-zip

 

Restart the apache2 service and Run the following command to verify PHP is installed correctly

 

sudo nano /var/www/html/phpinfo.php

 

It creates a phpinfo.php file at /var/www/html/ directory. You will need to install the Magento2 setup here only.

 

Type or paste the below and save the file.

 

<?php phpinfo( ); ?>

 

Browse to this Url "http://localhost/phpinfo.php" and you will see an image similar to this.

 

Now we need to create a Database for our Magento2 setup

Run the following command and log in using your DB password

 

sudo mysql -u root -p

 

Create a new database "magento_shop" or by any name using the following command 

 

CREATE DATABASE magento_shop

 

Now create a user with a new password other than your root password

 

CREATE USER 'magento2user'@'localhost' IDENTIFIED BY 'your_new_password';

 

Now Grant all the permission for your DB to this user 

 

GRANT ALL ON magento_shop.* TO 'magento2user'@'localhost' IDENTIFIED BY 'your_new_password' WITH GRANT OPTION;

 

After this save the changes and Exit

 

FLUSH PRIVILEGES;

EXIT;

 

As we are going to install Magento2 using composer, we need to install the composer too.

curl -sS https://getcomposer.org/installer -o composer-setup.php

 

after this run the following command to verify composer has installed successfully.

 

composer

You will get an output similar to the below

   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 1.1.1 2016-05-17 12:25:44

Usage:
  command [options] [arguments]

Options:
  -h, --help                     Display this help message
  -q, --quiet                    Do not output any message
  -V, --version                  Display this application version
      --ansi                     Force ANSI output
      --no-ansi                  Disable ANSI output
  -n, --no-interaction           Do not ask any interactive question
      --profile                  Display timing and memory usage information
      --no-plugins               Whether to disable plugins.
. . .

 


About Author

Harsh Soni

Harsh is an experienced software developer with a specialization in the MEAN stack. He is skilled in a wide range of web technologies, including Angular, Node.js, PHP, AWS, and Docker.Throughout his career, Harsh has demonstrated a strong commitment to delivering high-quality software solutions that meet the unique needs of his clients and organizations. His proficiency in Angular and Node.js has allowed him to build dynamic and interactive user interfaces, leveraging the power of modern front-end frameworks. Harsh's expertise also extends to cloud computing and infrastructure management using AWS, enabling him to design and deploy scalable applications with ease. Additionally, his knowledge of Docker has enabled him to streamline the development and deployment process, enhancing efficiency and reducing time-to-market. He excels at analyzing complex technical challenges and devising efficient strategies to overcome them, ensuring the successful completion of projects within deadlines.

Request For Proposal

[contact-form-7 404 "Not Found"]

Ready to innovate ? Let's get in touch

Chat With Us