How to Install and Setup Magento 2 on Ubuntu 19.04

Magento is an e-commerce platform built on open source technology which provides online merchants with a flexible shopping cart system, as well as control over the look, content, and functionality of their online store. 

Magento offers powerful marketing, search engine optimization, and catalog-management tools. There exist more e-commerce platforms like Woo-commerce, Shopify, BigCommerce, etc. But Magento is the leader in this category because of its open-source nature.

Recently Adobe the tech giant acquired Magento and so the trust in this product is doubled. This deal is maybe so important for Magento because of the security options and experience in the tech industry of Adobe can also be applicable to Magento also.

Here we are going to learn the steps in installing Magento 2 on Ubuntu 19.04 operating system.



Installation

1. Install Apache2

Magento requires a webserver to run. The commonly used web servers today are, Apache2 and NGINX. In this guide, we are using Apache2. We can install Apache2 with the below command.

sudo apt-get install apache2

2. Install MySQL

Magento also needs a database server. Most using database with PHP is Mysql.

On Terminal,

sudo apt-get install mysql-server mysql-client

On Terminal,

sudo mysql_secure_installation

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

Enter current password for root (enter for none): (Press Enter)
Set root password? [Y/n]: Y
New password: (Enter password for mysql DB)
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

3. Install phpMyAdmin

phpMyAdmin is a free software tool written in PHP, intended to handle the administration of MySql over the Web. It can be installed using the command below.

sudo apt-get install phpmyadmin

It will ask for the MySQL credentials and we have to give it properly.

We can access the phpMyAdmin panel using the link below.

http://localhost/phpmyadmin

Note:-

if it is giving an error “The requested URL /phpmyadmin was not found on this server”, do the below steps.

  • Open apache2.conf file using nano editor.
sudo -H nano /etc/apache2/apache2.conf
  • Paste the following line to the end of the file.
Include /etc/phpmyadmin/apache.conf
  • Restart apache server
/etc/init.d/apache2 restart

4. Install PHP and it’s extensions

Magento is made with PHP and is necessary to install PHP and PHP extensions on our system.

sudo add-apt-repository ppa:ondrej/php sudo apt-get update 
sudo apt-get install -y php7.1 libapache2-mod-php7.1 php7.1-common php7.1-gd php7.1-mysql php7.1-mcrypt php7.1-curl php7.1-intl php7.1-xsl php7.1-mbstring php7.1-zip php7.1-bcmath php7.1-iconv php7.1-soap

5. Configure Virtualhost

Configuring the Virtualhost is the next part. It can be done in the following steps.

sudo nano /etc/apache2/sites-available/magento.conf

This gives us an editing panel inside our terminal. We have to copy and paste the below code to the nano editor. While we are trying to paste the code in the editor, Ctrl + V won’t work. So we have to paste the code by right-clicking on the editor and clicking the paste button.

<VirtualHost *:80>
    DocumentRoot /var/www/html
    <Directory /var/www/html/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
    </Directory>
</VirtualHost>

After pasting the code, we must save it by pressing Ctrl + O. Then exit the nano editor by pressing Ctrl + X.

Now enable the Magento.conf and disable default configuration.

sudo a2ensite magento.conf
sudo a2dissite 000-default.conf

6. Download Magento 2.3.2

Now download Magento 2.3.2 zip file using GitHub repository URL below.

https://github.com/magento/magento2/archive/2.3.2.zip

Alternative way

We can also download Magento2 from official Magento website URL below.

https://magento.com/tech-resources/download

The zip file will be downloaded to the /Downloads folder.

Then unzip the magento2-2.3.2.zip to a directory called AwesomeProject. It can be easily done with the terminal.

cd Downloads
unzip magento2-2.2.5.zip -d AwesomeProject

7. Choosing the Project Destination

We need to choose /var/www/html as the project destination because it is the default root folder of the webserver of our ubuntu system.

So, move the AwesomeProject directory from /Downloads to /var/www/html .

sudo mv AwesomeProject /var/www/html

8. Setting Permission For the Project Directory

We must set permissions for working with our project directory because as by default our system may only allow us to change the contents in our project directory as root.

sudo chmod 777 -R /var/www/html/AwesomeProject

9. Create a Database

We have to create a database on our Mysql server for our Magento application. This can be simply done from the phpMyAdmin panel.

  • Go to https://localhost/phpmyadmin and Enter username and password(As a default, the username will be root and password will be our Mysql password).
  • Click on the New tab
  • Enter a database name (eq:- “sampledb”)

Press Create

10. Setting up the Magento App

Now Enter the below URL on our browser tab.

https://localhost/AwesomeProject

It will open a web interface for setting up our Magento project. If we have already experienced in setting up WordPress, it will be easy for us to setup Magento.

It can easily be caught by us from the screenshots of the procedure of installation which is shown below.

Initial Page of Magento Installation Setup
Checking Our Environment for Correct PHP version and PHP Extensions
The result of the Readiness Check
Database Details To Be Filled By Us
Web Configuration Page: Url Of Our New Magento App and Admin Url have to set from here.
Store Customization Setup
Admin Account Configuration
We Are Ready to Install Page
Installing-Page

11. Opening the Application

So our Magento app is ready to serve. To see the application put the below URL on our browser.

http://localhost/AwesomeProject

The above address loads default theme of Magento (Luma) on our browser.

To get the admin panel of our Magento application, use the below URL.

http://localhost/AwesomeProject/admin

Have a nice code !

Be the first to reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.