Magento 2.4.2 Windows Installation

Abdul Rafay
3 min readFeb 19, 2021

--

Step#1
Download Magento archive from
https://magento.com/tech-resources/download

Step#2
Create Alias or Virtual host in your system and extract the zip into specific directory

Update the .htaccess file in the root directory and add the root folder
old RewriteRule .* /pub/$0 [L]
new RewriteRule .* /magento242/pub/$0 [L]

Step#3
Access the URL to check if its working or not.
http://127.0.0.1/magento242/index.php

Step#4
Run composer install / composer update commands to update dependency

Step#5
Download and install the Elasticsearch windows version using this url
https://www.elastic.co/guide/en/elasticsearch/reference/current/windows.html

Step#6
Update File Gd2.php

Make sure GD2 extension is installed and enabled in the php.ini file.

Replace the function validateURLScheme with below code https://github.com/magento/magento2/blob/2.3.5-p2/lib/internal/Magento/Framework/Image/Adapter/Gd2.php#L96

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;
}

After:

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;
}

Step#7
Uncomment the extension

;extension=sodium.s in php.ini

Step#8
Update File Generator.php

\vendor\magento\framework\Interception\PluginList
Generator.php on line 414
From
$cacheId = implode(‘|’, $this->scopePriorityScheme) . “-” . $this->cacheId;
To
$cacheId = implode(‘-’, $this->scopePriorityScheme) . “-” . $this->cacheId;

Step#9
Update File Validator.php

/vendor/magento/framework/View/Element/Template/File/Validator.php In this file find:

$realPath = $this->fileDriver->getRealPath($path);

Replace it with

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

Step#10
Magento2 CLI Installation command

php bin/magento setup:install — base-url=”http://127.0.0.1/{root directory}/" — db-host=”localhost” — db-name=”db_name" — db-user=”root” — db-password=”root” — admin-firstname=”abdul” — admin-lastname=”rafay” — admin-email=”abdulrafay.aalogics@gmail.com” — admin-user=”admin” — admin-password=”admin123" — language=”en_US” — currency=”USD” — timezone=”America/Chicago” — use-rewrites=”1" — backend-frontname=”admin” — elasticsearch-host={elastic_search_url} — elasticsearch-host=”127.0.0.1” — elasticsearch-port=“9200” — elasticsearch-username=”username” — elasticsearch-password=”{password}”

Step#11
Access the Magento from Alias/Virtualhost

Access using Alias http://127.0.0.1/magento242
OR
Access using Virtualhost http://magento242

--

--

Abdul Rafay

MS CS — Software Engineer @Systems Limited with expertise in PHP/Python, worked on popular CMS and frameworks like Magento/Wordpress/Codeigniter/Odoo.