Free AI shopping readiness review for Shopify, Magento and WooCommerce storesRequest yours
Blog

Next Magento security release: Tuesday, Dec 8, 2026Get patch help

Talk to an engineer

How to Install Magento 2 in Ubuntu Step by Step 2024

M-Connect MediaPublished
Updated
Reading time
4 minutes

Quick Summary

As per the Internet sources, Magento is the second most popular E-commerce platform. It requires development units to be connected to servers for storing the codes and checking the output. Ubuntu is based on Linux systems are based on the servers. Hence, it is very easy for Magento website development. Over and above, Ubuntu is freely available. It does not require the license like windows or Mac. So, here is the complete installation process for Magento 2 in Ubuntu.

System Requirements

  • A cloud server with at least 4 GB space as PHP and Magento requires 2 GB of space.
  • Magento runs on a LAMP stack (Linux, Apache, MySQL, and PHP). You can quickly install Apache, MySQL, and PHP using Tasksel and get it running fast.
  • Configure Apache version 2.2 or 2.4 and Virtual Hosts
    • Create a new virtual host file test.com.conf for your Magento site at the following path:
      • /etc/apache2/sites-available/
      • $ sudo nano /etc/apache2/sites-available/test.com.conf
    • Next, add the below mentioned lines to the file:
      • <VirtualHost *:80>
      • ServerName test.com
      • ServerAlias www.test.com
      • ServerAdmin webmaster@localhost
      • DocumentRoot /var/www/html/test.com/
      • ErrorLog /var/www/html/test.com/logs/error.log
      • CustomLog /var/www/html/test.com/logs/access.log combined
      • <Directory /var/www/html/test.com/>
      • Options Indexes FollowSymLinks MultiViews
      • AllowOverride All
      • </Directory>
      • </VirtualHost>
    • Do not forget to save and close the file.
    • Moving further, enable the new virtual host and mod_rewrite module.
      • $ sudo a2ensite test.com.conf
      • $ sudo a2enmod rewrite
    • Then, disable the default virtual host configuration to avoid any conflict with the newly created one.
      • $ sudo a2dissite 000-default.conf
    • Restart the Apache service.
      • $ sudo service apache2 restart
    • Create a MySQL Database (version 5.6 or later) and user
      • A new database and user are recommended for fresh Magento installation. Login to your database using root user.
      • $ mysql -u root –p
      • First, create a new user and then the new database.
      • mysql> CREATE USER magento@localhost IDENTIFIED BY “your_password_here”;
      • mysql> create database magento;
      • Now, grant all privileges to the database, flush privileges, and exit.
      • mysql> GRANT ALL ON magento.* TO magento@localhost;
      • mysql> FLUSH PRIVILEGES;
      • mysql> exit
    • Configure PHP 7.0
      • $ apt-get update && apt-get upgrade
      • $ sudo apt-get install php7.0-common php7.0-gd php7.0-mcrypt php7.0-curl php7.0-intl php7.0-xsl php7.0-mbstring php7.0-zip php7.0-iconv mysql-client mysql-server

How to Install Magento 2?

Magento is open-source, hence you can easily download from its official website. Many versions will be available for download but opt for the latest release. Once the download is complete, extract the downloaded file and copy the contents to the following path using root permission:

/var/www/html

Then set Apache ownership to the files and folders.

$ sudo chown -R www-data:www-data /var/www/html/test.com/

Now, to be presented with Magento installation wizard, open the following URL in your browser:

http://server_domain_name_or_IP/

Install Magento 2

In the first step of the installation process, you will have to accept the “Terms and Agreement” and click “Continue”. Then it will perform the “Readiness Check” for all the system requirements mentioned above. Click next to enter Magento database settings. Enter the required valid details to move forward.

Next step is “Website Configuration” where you need to enter your store address and Magento admin address. It will be preferable to give a unique admin address other than /admin to keep your store secured.

Next comes “Customize your Store” by setting time zone, currency and language. Then “Create Admin Account” by filling in the required details. You are now ready to “Install”!

Magento Configuration

Launch the Magento admin to configure it. It gives lots of options for configuration, you can download the user guide from Magento to ease out the configuration process.

Hope you had a fun time installing Magento 2 on your Ubuntu system.

Need any help while installing? Talk to our Magento eCommerce consultant anytime!!

Once the install works, our free Magento health check module confirms that cron, indexers and caches are set up correctly. Our other free Magento 2 extensions install the same way with Composer.

Written by M-Connect Media

Since the foundation in 2009, M-Connect Media has been serving the best of its services to Magento as well as the eCommerce community. The company believes in delivering the best quality projects to their clients within the timeline, by meeting their expectation levels. The company’s success is supported by their Magento certified team and eCommerce industry experts.

More from M-Connect Media →

Stuck on Magento? Ask an engineer.

Tell us your version and what is going wrong. We reply within one business day with next steps.

info@mconnectmedia.com
+1 319 804-8627