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.
Get our best content on eCommerce and backend operations to optimize your distribution business for profitability in your inbox one time a week.
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)
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.
- Extract Magento 2.4.1 files to your xampp/htdocs folder.
- Check Weather your PHP Extensions are all installed:
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.
Click Next, and browse to the path of the PHP in the XAMPP folder.
Now click Install to initiate the final step.
Launch the Command Prompt and run the Composer command to verify that it has been installed without any issues.
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.
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.
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 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.
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=”firstname.lastname@example.org” –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=9200Please note: Assign the base URL as per your path, note down the admin username and password and do not the Elasticsearch port.
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.
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.
- php bin/magento indexer:reindex
- php bin/magento setup:upgrade
- php bin/magento setup:static-content:deploy -f
- php bin/magento cache:flush
Now hit the URL (usually, localhost/magento2) or the base URL that you set earlier for the installation.
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 …vendormagentoframeworkViewElementTemplateFileValidator.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:
- 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
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.