Step-by-Step Guide to Installing Magento 2

Step-by-Step Guide to Installing Magento 2

 Installing Magento 2

The Magento 2 platform offers a wide range of features and flexibility that are essential for online stores to succeed. In my last article I talked about why Magento 2 is the best platform to create an e-commerce website.

However, some users may find it challenging to install Magento 2 because it has a long list of technical requirements.

From understanding the system requirements to following end-to-end steps with the right approach can make it easy to install Magento 2 and bring your brings back to track with promising features. 

Here we have put together a step-by-step guide to install Magento 2.

System Requirements to Install Magento 2

The system requirements include the following: 

      • Operation System: Ubuntu, Debian, or CentOS are among the suggested Linux distributions.

      • Web server: Nginx 1. x or Apache 2.4.

      • Database: 10.x MariaDB or MySQL 5.6+.

      • PHP: Version 7.3 or 7.4, with the following extensions enabled:

      • bc-math

      • ctype

      • curl

      • dom

      • gd, ImageMagick 6.3.7+ (2.0.34+)

      • intl

      • mbstring

      • OpenSSL

      • PDO/MySQL

      • SimpleXML

      • soap

      • XM

      • xsl

      • zip

      • JSON

    Step-by-Step Magento 2 Installation Process

    The Magento 2 installation process brings along a range of steps that you must take to ensure a seamless Magento 2 installation process. Here are step-by-step process for Magento 2 installation:

    Step 1: Install & Configure Apache2 Server & PHP Extensions

    Apache is an open-source web server that is used in Ubuntu for hosting the website and for this purpose you will have to install Magento 2.

    Run the following commands to install Apache in Ubuntu

    12 sudo apt updatesudo apt install apache2

    To auto-run Apache2 during system startup, use the following command:

    1 sudo systemctl enable apache2.service

    Create a magento2. conf file using the following command to declare Magento 2 site configuration for Apache2

    1 sudo nano /etc/apache2/sites-available/magento2.

    Now, open the created file confident to see that it has the heading contents as desired. Copy and paste the following configuration into it

    2345678 ServerAdmin webmaster@localhostDocumentRoot /var/www/htmlErrorLog ${APACHE_LOG_DIR}/error.logCustomLog ${APACHE_LOG_DIR}/access.log combined      ServerName your-magento-2-store-url.com    DocumentRoot /var/www/html/magento2/pub

    Please do not forget to replace the server address with your real Magento 2 store link, which is written as “your-magento-2-store-url. com”

    If installing Magento 2 is done on Ubuntu locally, you may change it to localhost. com. You will also have to make some changes to the /etc/hosts file as well.

    <div><br>127.0.0.1 your-magento-2-store-URL.com</div>

    1 127.0.0.1 your-magento-2-store-url.com

    Run the following command to enable mod rewrite:

    12 sudo a2ensite magento2.confsudo a2enmod rewrite

    Step 2: Install Database Server

    Since Magento 2 and Adobe Commerce, MariaDB is one of the most popular database servers. To install MariaDB server and client in Ubuntu, run the following command:

    1 sudo apt-get install mariadb-server mariadb-client

    To auto-start the database server on system startup, run the following command:

    12 sudo systemctl restart mariadb.servicesudo systemctl enable mariadb.service

    Now, run the following command to set up a MariaDB server in Ubuntu:

    1 sudo mysql_secure_installation

    Select the following options when prompted:

        • Enter current password for root (enter for none): Press Enter

        • Set root password? [Y/n]: Y

        • New password: Enter your password

        • Re-enter new password: Please enter your password

        • Remove anonymous users? [Y/n]: Y

        • Disallow root login remotely? [Y/n]: Y

        • Delete the test database and open it. [Y/n]: Y

        • Reload privilege tables now? [Y/n]: Y

      Step 3: Select MySQL User

      Magento 2 can not be installed directly under the root user in the operation system by default. That means you will have to create a new user for the database.

      Run the following command to log into MariDB:

      sudo mysql -u root -p

      Now, run the following command to create a new database

      CREATE DATABASE magento2

      Create a new user called ‘XYZ’ using the following command

      CREATE USER ‘XYZ’@’localhost’ IDENTIFIED BY ‘YOUR_PASSWORD’;

      Grant user to magento2 database:

      1 GRANT ALL ON magento2.* TO ‘XYZ’@’localhost’ IDENTIFIED BY ‘YOUR_PASSWORD’ WITH GRANT OPTION;

      Finally, flush the privileges and exit.

      12 FLUSH PRIVILEGES;EXIT

      Step 4: Install Composer

      Composer is a must for Magento 2 for managing the dependencies. You can either download and install Composer in Ubuntu manually or run the following command to do that:

      1 curl -sS https://getcomposer.org/installer | sudo php — –install-dir=/usr/local/bin –filename=composer

      To check if the Composer has been successfully installed, run the following version check command:

      1 composer -v

      Step 5: Download & Install Magento 2 in Ubuntu

      Go to one of these resources and download the zip file of the latest Magento 2 version:

          1. Magento 2 Releases on GitHub
            Now, extract the zip file to the /var/www/html/ folder.

            1. Download through composer
              You can download the latest version of Magento by using Composer as it handles dependencies and updates more efficiently.

              There are two main ways to install Magento 2 using Composer for Magento, Open Source and Adobe Commerce. Choose the method that suits your needs.

          Magento Open Source

          composer create-project –repository-url=https://repo.magento.com/ magento/project-community-edition Magento 2 

          Adobe Commerce

          composer create-project –repository-url=https://repo.magento.com/ magento/project-enterprise-edition Magento 2

                                  Run the following command to set the permissions:

          12 sudo chown -R www-data:www-data /var/www/html/magento2/sudo chmod -R 755 /var/www/html/magento2/

          Install Magento 2 on Ubuntu

          Open the /var/www/html/magento2 folder and run the following command:

          php bin/magento setup:install –base-url=https://magento2.com/ –db-host=127.0.0.1 –db-name=magento2 –db-user –db-password=password –admin-firstname=admin –admin-lastname=admin –admin-email=admin@admin.com –admin-user=admin –admin-password=admin123 –languag e=en_US –currency=USD –timezone=America/Chicago –use-rewrites=1 –backend-frontname=”admin” –search-engine=elasticsearch7

          The above command installs Magento 2 on Ubuntu with the preset configuration setting. Below, you can find the necessary parameters which you can modify to install Magento 2 as required: For e. g., there is an ability to change the login username and password.

          Once the command has been executed successfully, one is able to access the Magento 2 in the local server.

              • Frontend URL: https://magento2.com/

              • Admin Login URL: https://magento2.com/admin

              • Admin Username: admin

              • Admin Password: admin123

            That’s it! Well done; congratulations for successfully installing the Magento 2 store on your Ubuntu server.

            Conclusion

            Though it may seem difficult, installing Magento 2 can be done effectively by following this detailed tutorial. To safeguard and maximize your business, don’t forget to set up your server environment, properly complete each installation process, and take care of post-installation chores. Magento 2 gives your clients a rich and customized shopping experience on a strong platform that can grow with your company.


            For more insights on enhancing your e-commerce platform, check out our previous blog on  why choose Magento 2 for your E-
            commerce Business. This can help you understand how to improve customer interactions and support.

            Please follow and like us:

            2 Comments

              • Thank you so much for your kind words! We truly appreciate your feedback and support. we are glad that you found the information helpful, and we ’ll continue to share more insights. Stay tuned!

            Leave a Reply

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