Composer in a step-by-step tutorial.

Magento 2 has very specific server requirements that require a lot of server configuration and tweaking, along with setting up Composer (not a default option at many platforms). 

Let me clear up why Composer is really important for Magento 2. Composer is an essential requirement for managing the Magento system, extensions, the involved dependencies, and for declaring libraries for the project.

Before you start, you need to have these things at hand:

1: XAMPP Server installed on your computer with the latest PHP 7.3 or 7.4.

2: Download Magento 2.4.1 along with sample data (You can download Magento 2 from this link)

How to install Magento 2.4.1

3:Here are the basic Magento 2.4.1 server requirements:

  • Apache Version 2.2 or 2.4
  • PHP Version 7.3.x or 7.4.x
  • MySQL Version 5.6.x, 5.7.x
  • Elasticsearch 7.6.x or higher

Here I will cover the entire process of installing Magento 2 on localhost so that you would not  face any issues in replicating the process:

  • Open the XAMPP server and start Apache and MySQL applications.

How to install Magento 2.4.1

  • Extract Magento 2.4.1 files to your xampp/htdocs folder.
  • Check Weather your PHP Extensions are all installed:
  • ext-bcmath
  • ext-ctype
  • ext-curl
  • ext-dom
  • ext-gd
  • ext-hash
  • ext-iconv
  • ext-intl
  • ext-mbstring
  • ext-openssl
  • ext-pdo_mysql
  • ext-simplexml
  • ext-soap
  • ext-xsl
  • ext-zip
  • lib-libxml

Install Composer

Download and run Composer-Setup.exe. This will install the latest version and set up your path so that you can “call” Composer from any directory.

How to install Magento 2.4.1

Click Next, and browse to the path of the PHP in the XAMPP folder.

How to install Magento 2.4.1

Now click Install to initiate the final step.

How to install Magento 2.4.1

How to install Magento 2.4.1

Launch the Command Prompt and run the Composer command to verify that it has been installed without any issues.

How to install Magento 2.4.1

 After installing the composer, you must enable the extension (php_intl.dll) in the php.ini file. To enable the extension, edit php.ini and uncomment the line “extension=php_intl.dll” and just remove the semicolon “;” from the starting of the line. Next, restart the XAMPP control panel.

Install Elasticsearch for Magento 2.4.1

Elasticsearch is a highly recommended extension for Magento 2.4.1.

Download and install the latest version of Elasticsearch from here. Once installed, run the bash file as an administrator. 

How to install Magento 2.4.1

 You can also check the availability of Elasticsearch on port:9200. Type local:9200 in the browser and you will get the details of the installed Elasticsearch extension.

How to install Magento 2.4.1

Create a Database for Magento 2.4.1

Access localhost/phpmyadmin, create a database. 

IMPORTANT Remember the name of the database you would create.

Magento 2.4.1

Magento 2.4.1 Installation

First, unzip the downloaded Magento 2.4.1 file to xampp/htdocs/. After this, go to the Magento 2 folder (inside the htdocs folder).

Hold the Shift key and right-click, and select “Open command window here”. This will open a command prompt on the location.

Magento 2.4.1

In the command prompt, execute the command:

$ php bin/magento setup:install –base-url=”http://localhost/magento2/” –db-host=”localhost” –db-name=”dbmagento241″ –db-user=”root” –admin-firstname=”admin” –admin-lastname=”admin” –admin-email=”user@example.com” –admin-user=”admin” –admin-password=”admin123″ –language=”en_US” –currency=”USD” –timezone=”America/Chicago” –use-rewrites=”1″ –backend-frontname=”admin” –search-engine=elasticsearch7 –elasticsearch-host=”localhost” –elasticsearch-port=9200

Please note: Assign the base URL as per your path, note down the admin username and password and do not the Elasticsearch port.

Magento 2.4.1

After you give that command please wait for a while to load modules and all required files for Magento 2.4.1. 

After the installation, you will end up with these results.

Magento 2.4.1

If you hit the URL, you might won’t see the updated content with sample data on the storefront.

For that, you need to run the following commands.

  1. php bin/magento indexer:reindex
  2. php bin/magento setup:upgrade
  3. php bin/magento setup:static-content:deploy -f
  4. php bin/magento cache:flush

Now hit the URL (usually, localhost/magento2) or the base URL that you set earlier for the installation.

Magento 2.4.1

Congratulations! You have now successfully installed Magento 2..4.1 on your localhost. You can now start making your preferred customizations and launch a fully functional ecommerce store right on the local machine.

Problems During Magento 2.4.1 Installation

There is a chance that you might encounter an issue during the Magento 2 installation process. Here are some of the most common ones, along with a solution.  

  • Blank Grey Page – Magento Admin Panel

All you have to do is go to the directory path …\vendor\magento\framework\View\Element\Template\File\Validator.php

 In the function isPathInDirectories, add a line.

  • $realPath = str_replace(‘\\’, ‘/’, $this->fileDriver->getRealPath($path));

Refer to the following image for the point where you need to insert the line:

Magento 2.4.1

  • If You Get an Authentication Error

If you couldn’t log in to the Magento Admin Panel and encounter an authentication error, simply run the following command in the Composer:

  • php bin/magento module:disable Magento_TwoFactorAuth

Magento 2.4.1

 

Learn more about the intricacies of Magento 2.4.1 installation. Get in touch with our Magento developers to optimize your B2B eCommerce website for high-performance.

Author

  • Ajith Deevannagari

    Ajith Deevannagari is a UI Developer at DCKAP. As committed as ever, he nurtures his passion for learning to expand the knowledge base in his field of work. Apart from being a 3D Art hobbyist, Ajith has forayed into writing informative articles on the subjects that add value to the digital commerce arena.

READY TO DRIVE SALES?

Ready to drive online revenue

Get In Touch

Leave a Reply

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