How to Install Magento 2.4.xx: Step-by-Step Installation Guide – 2025
Installing Magento 2.xx involves several critical steps to ensure a smooth and efficient setup. Magento is a robust eCommerce platform that requires proper server configuration and software dependencies. Begin by setting up a local development environment, often using XAMPP or a similar tool. Update the php.ini
file to enable required PHP extensions like soap
, gd
, intl
, and set the memory limit to 4GB.
Next, configure a virtual host by modifying the httpd-vhosts.conf
file and update the hosts
file to map a custom domain (e.g., acesoftech.local
). Download and install Composer, a dependency manager, and use Magento’s access keys to fetch the community edition package. Install Elasticsearch 7.x, essential for Magento’s search functionality, and verify it runs successfully.
Run the Magento installation command, specifying database credentials, admin details, and search engine configuration. After installation, finalize the setup by clearing the cache, reindexing data, and deploying static content. To troubleshoot issues, disable two-factor authentication if needed or resolve file path validation errors by modifying core files like Gd2.php
and Validator.php
.
With Magento 2.xx successfully installed, you can access the storefront and admin panel, ready to build a feature-rich eCommerce website tailored to your business needs.
Composer download and install
1. Install Composer
- Download Composer from https://getcomposer.org/.
composer update
2. Windows Environment Setup
Edit hosts File: Add this line to C:\Windows\System32\drivers\etc\hosts:
127.0.0.1 acesoftech.local
3. Xampp related Configuration
php.ini changes
PHP extension:
extension=soap extension=sockets extension=sodium extension=sqlite3 extension=tidy extension=xsl extension=zip extension=gd extension=intl
Open the file located at:
C:\xampp\php\php.ini
Search for the following line:
php.ini
memory_limit = 128M
memory_limit = 4G
Create virtual host
Edit httpd-vhosts.conf: Add this configuration in C:\xampp822\apache\conf\extra\httpd-vhosts.conf:
apache
<VirtualHost *:80> DocumentRoot "C:/xampp822/htdocs/magento/pub" ServerName acesoftech.local <Directory "C:/xampp822/htdocs/magento/pub"> Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Require all granted </Directory> </VirtualHost>
Restart Apache
Use the XAMPP Control Panel to restart Apache.
- Access Key from Magento
Create an Account
Visit Magento Marketplace.
4.Click on Sign In > Create an Account and complete the registration.
Obtain Access Keys
After logging in, go to My Profile > Access Keys (under the Marketplace tab).
Click Create a New Access Key.
- Provide a name for your key (e.g., “Magento Setup Key”).
Save the Public Key (username) and Private Key (password).
5. Magento Download
composer global config http-basic.repo.magento.com <public_key> <private_key>
Replace <public_key> and <private_key> with your Magento access keys.
Navigate to your desired directory (e.g., C:\xampp\htdocs) and run:
composer create-project –repository-url=https://repo.magento.com/ magento/project-community-edition magento
6. Elasticsearch Setup
- Download Elasticsearch
- Download Elasticsearch 7.x compatible with Magento 2.4 from https://www.elastic.co/downloads/elasticsearch.
- Install and Configure Elasticsearch
- Extract the Elasticsearch archive (e.g., C:\xampp822\htdocs\elasticsearch-7.16.3).
Open the terminal and navigate to the bin folder:
cd C:\xampp822\htdocs\elasticsearch-7.16.3\bin
Run: elasticsearch.bat
- Test Elasticsearch
Open a browser and go to http://localhost:9200. You should see the Elasticsearch JSON response.
7.Trouble shoots before / while installing
vendor\magento\framework\Image\Adapter\Gd2.php
Before
private function validateURLScheme(string $filename) : bool { $allowed_schemes = ['ftp', 'ftps', 'http', 'https']; $url = parse_url($filename); if ($url && isset($url['scheme']) && !in_array($url['scheme'], $allowed_schemes)) { return false; } return true; }
Change it to
private function validateURLScheme(string $filename) : bool { $allowed_schemes = ['ftp', 'ftps', 'http', 'https']; $url = parse_url($filename); if ($url && isset($url['scheme']) && !in_array($url['scheme'], $allowed_schemes) && !file_exists($filename)) { return false; } return true; }
Open app/etc/di.xml.
Locate the following line:
xml
Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink
Replace it with:
Magento\Framework\App\View\Asset\MaterializationStrategy\Copy
This ensures Magento uses file copying instead of symbolic links, which are not always supported on
==============================================================================
If you see blank screen after installation
Magento\Framework\View\Element\Template\File\Validator
function isPathInDirectories replace below code in isPathInDirectories function
C:\xampp\htdocs\magento\vendor\magento\framework\View\Element\Template\File\validator.php
// $realPath = $this->fileDriver->getRealPath($path); // foreach ($directories as $directory) { // if ($directory !== null && 0 === strpos($realPath, $directory)) { // return true; // } // } // return false;
$realPath = $this->fileDriver->getRealPath($path); foreach ($directories as $directory) { // Get the real path of each directory in the list $directoryRealPath = $this->fileDriver->getRealPath($directory); // Check if the real path of the file starts with the real path of the directory if ($directoryRealPath !== false && 0 === strpos($realPath, $directoryRealPath)) { return true; } } return false;
7.Create Database
Open phpmyadmin and create database
8. Magento Installation
Run the Magento setup command:
php bin/magento setup:install \
–base-url=”http://acesoftech.local/” \
–db-host=”localhost:3308″ \
–db-name=”magento3″ \
–db-user=”myadmin” \
–db-password=”Angular13″ \
–admin-firstname=”admin” \
–admin-lastname=”admin” \
–admin-email=”saz3sumar@gmail.com” \
–admin-user=”admin” \
–admin-password=”Admin123!” \
–language=”en_US” \
–currency=”USD” \
–timezone=”America/Chicago” \
–search-engine=elasticsearch7 \
–elasticsearch-host=”localhost” \
–elasticsearch-port=9200 \
–use-rewrites=1
For CMD single line
php bin/magento setup:install –base-url=”http://magento.local/” –db-host=”localhost:3306″ –db-name=”magento” –db-user=”root” –db-password=”admin” –admin-firstname=”admin” –admin-lastname=”admin” –admin-email=”saz3sumar@gmail.com” –admin-user=”admin” –admin-password=”Admin123!” –language=”en_US” –currency=”USD” –timezone=”America/Chicago” –search-engine=elasticsearch7 –elasticsearch-host=”localhost” –elasticsearch-port=9200 –use-rewrites=1
If this problem arises
C:\xampp\htdocs\magento>php bin/magento admin:user:unlock admin
9. Post-Installation Commands
Run these commands to finalize the setup:
php bin/magento cache:clean
php bin/magento cache:flush
php bin/magento indexer:reindex
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy -f
Reindex Data:
php bin/magento indexer:reindex
- Upgrade Setup:
- php bin/magento setup:upgrade
Deploy Static Content:
php bin/magento setup:static-content:deploy -f
Clear Cache:
php bin/magento cache:flush
Problem:
Solution:
Disable Two-Factor Authentication (Optional):
php bin/magento module:disable Magento_AdminAdobeImsTwoFactorAuth Magento_TwoFactorAuth
10. Optional: Install Sample Data
Enable Developer Mode:
php bin/magento deploy:mode:set developer
Deploy Sample Data:
php bin/magento sampledata:deploy
php bin/magento setup:upgrade
php bin/magento cache:clean
php bin/magento setup:static-content:deploy en_US -f
11. Elasticsearch Troubleshooting
If you encounter disk allocation errors with Elasticsearch, run the following commands:
Disable disk threshold checks:
curl -X PUT -H “Content-Type: application/json” http://localhost:9200/_cluster/settings -d “{ \”transient\”: { \”cluster.routing.allocation.disk.threshold_enabled\”: false } }”
Clear read-only blocks:
curl -X PUT -H “Content-Type: application/json” http://localhost:9200/_all/_settings -d “{ \”index.blocks.read_only_allow_delete\”: null }”
12. Test and Access
- Access the Magento storefront:
http://acesoftech.local - Access the Magento Admin panel:
http://acesoftech.local/admin
Use the admin credentials you set during installation.