Recommended: Magento2 codebase and database backup automation script

Step 1 – Install LAMP

You can use the following commands to install all requirements from default repositories. Then install PHP and other required PHP modules. You can use MySQL or MariaDB as the database server for the Magento application. Once the installation finished, run the mysql_secure_installation script to create a password for the root account and secure the MySQL server. The LAMP environment is completed on your system. Move to next step:

Step 2 – Install Composer

This tutorial required PHP composer to complete the installation. To install the PHP composer on your system execute following commands:

Step 3 – Download Magento 2 Archive

You can download the Magento source code from the official Github repository or website. After finishing the download After downloading the archive file, extract it under the website document root. So we can access directly from the web browser. After placing Magento files to the proper location, use composer to install required libraries Then, set the proper permission on the files to run with Apache webserver.

Step 4 – Create Database and User

Magento uses MySQL as a backend database server. Login to your MySQL server with admin privileges and create a database and user for the new Magento 2 installation.

Step 5 – Create Apache VirtualHost

Create an Apache configuration file for your Magento website like /etc/apache2/sites-available/ and add the following content. Now enable virtual host using the following command. Also make sure to enable the Apache rewrite module, which is recommended by Magento. After doing all the above changes, make sure to restart the Apache server.

Step 6 – Run Web Installer

Let’s begin the installation of Magento2 using a web installer. Access your Magento 2 directory on the web browser like below. It will redirect you to the installation start page. 6.1. Agree the License agreement and click on “Agree and Setup Magento”

6.2. Now click on the “Start Readiness Test”. Magento will check for system requirements here. On successful completion, you will see the screen like below then Just click Next. Fix issues if shows on this screen and click Try again.

6.3. Enter your database details here created in step 4.

6.4. The installer will show you the store address (Same as we address). It also generates a random URL for the Admin interface. You can change it as per your requirements. For security reasons, it will not take the URL as admin.

6.5. Create an Admin user with a secure password for your Magento application.

6.6. At this step, Magento is ready for installation. Click on the Install Now button to begin installation and wait for its completion.

6.7. At this step, the Magento installation is completed.

6.8. Finally, it will open the Admin Login screen. Use admin credentials created during wizard. It will open the Admin panel after successful authentication.

Congratulation! You have successfully deployed Magento2 on your system.

Step 6 – Schedule Magento2 Cronjobs

Finally, schedule the background cronjobs for your magento2 installation. These cronjobs do some activities like re-indexing, Newsletters, Update of currency rates, sending automatic emails and generating sitemaps, etc. To schedule, these jobs edit the crontab file and add following cronjobs at the end of the file and save it. Here www-data is the user under which Apache is running and /var/www/magento2/ is the location of your Magento2 applications.


You have successfully configured the Magento application on your system. Let’s build an awesome eCommerce website. For the production, server follow our next tutorial to Magento codebase and database backup automation script.

How to Install Magento2 on Ubuntu 18 04   TecAdmin - 39How to Install Magento2 on Ubuntu 18 04   TecAdmin - 76How to Install Magento2 on Ubuntu 18 04   TecAdmin - 42How to Install Magento2 on Ubuntu 18 04   TecAdmin - 54How to Install Magento2 on Ubuntu 18 04   TecAdmin - 66How to Install Magento2 on Ubuntu 18 04   TecAdmin - 85How to Install Magento2 on Ubuntu 18 04   TecAdmin - 99How to Install Magento2 on Ubuntu 18 04   TecAdmin - 45