We will start by downloading Xampp, which we will use to create server and manage database.
You can download xamp from Apache Friends
https://www.apachefriends.org/download.html
Composer is a library management tool in PHP (Dependency Management), this tool saves us a lot of time with the necessary packages that your project needs to use, you just need to declare it, Composer will automatically download the code of the libraries through a community server.
You can download composer fron here
https://getcomposer.org/download/
-After donwloding the composer install it.
-Verfiy the composer installation by open command prompt and type
composer -v
Elasticsearch is a search engine based on the Lucene library. It provides a distributed, multitenant-capable full-text search engine with an HTTP web interface and schema-free JSON documents.
Elasticsearch is now a required application to install Magento 2. During installation process, the system will verify if Eleasticsearch was installed and configured properly. If there’s something wrong with Elasticsearch verification, the installation process will stop.
You can download elastic search from here
https://www.elastic.co/downloads/elasticsearch
-Download the zip file,
-Extract the file in htdocs folder inside the xampp foler
Next, unzip archived file at the “C:\xampp\htdocs\” as shown below and go to \elasticsearch-7.16.2\bin
-Run elasticsearch.bat as adminstrator.
-Terminal will open start running the elasticsearch. But make sure your apache is running in the xampp.
-Open Your Browser and type
localhost:9200
– A popup window will show asking for username & password these are by defaul set by magento2 which are
user: elastic
password: changeme
But we don’t elasticserch to be encrypted whenever we open it browser so we are going to override and stop the authentication.
To do that these are the steps we need to follow
-First open the elasticsearch.yml file using any text editor, the path is ” elasticsearch-8.9.1\config\elasticsearch.yml” inside the elasticsearch main folder
-Go to bottom of file and paste the below code.
xpack.security.enabled: false
xpack.security.enrollment.enabled: false
-It should look like this.
-Restart the elastic search and open the browser and open
localhost:9200
-The response in the browser should be like this.
Before installing Magento 2, we need to make sure to install and enable all required PHP extensions and configure some PHP values to make the installation go smoothly.
bcmath | ctype | curl | dom |
gd | dom | iconv | intl |
mbstring | openssl | pdo_mysql | simplexml |
soap | xsl | zip | ext-sockets |
-Go to C:\xampp\php\php.ini
-Remove ; from starting of the ;extension like this
-Also Search and update the values in php.ini file
max_execution_time=18000
max_input_time=1800
memory_limit=4G
-Save the file & restart the apache server.
-Start the mysql in the xampp application.
-Go to localhost/phpmyadmin
Next, input the following command to change mysql root password
mysqladmin.exe -u root password yourpassword
-Move to location “C:\xampp\htdocs”
-Open terminal there.
-Copy the below code and change “<install-directory-name>” with your choice of folder
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition <install-directory-name>
It will download magento2.
The Magento app is served from /var/www/html/magento2/pub
. The rest of the Magento file system is vulnerable because it is accessible from a browser. Setting the webroot to the pub/
directory prevents site visitors from accessing sensitive areas of the Magento file system from a browser.
-We need to set document root to pub, to do this go to file C:\xampp\apache\conf\extra\httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/magento2/pub"
ServerName testing.magento2.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
Where,
DocumentRoot "C:/xampp/htdocs/magento2/pub"
=> location of the magento2 folder path
Open C:\Windows\System32\drivers\etc\hosts file in notepad and add the below line at the bottom of the file.
127.0.0.1 testing.magento2.com
Now go to C:\xampp\htdocs\magento2
Open Terminal and below code
php bin/magento setup:install --base-url="http://yourname.magento.com/" --db-host="localhost" --db-name="magento2" --db-user="root" --db-password="root" --admin-firstname="admin" --admin-lastname="admin" --admin-email="user@example.com" --admin-user="admin" --admin-password="Admin@123456" --language="en_US" --currency="USD" --timezone="America/Chicago" --use-rewrites="1" --backend-frontname="admin" --search-engine=elasticsearch7 --elasticsearch-host="localhost" --elasticsearch-port=9200
Replace these values:
In PatchApplier.php line 172:
Unable to apply data patch Magento\Theme\Setup\Patch\Data\RegisterThemes for module Magento_Theme. Original exception message: Wrong file
In Gd2.php line 790: Wrong file
Solution
Here Image Adapter try opens to image files (‘open function in Gd2.php line 72). validateURLScheme function return false always because it checking ‘URL’ format but local files not valid for this format, so it returns false.
Find validateURLScheme function in vendor\magento\framework\Image\Adapter\Gd2.php file. at line 94. Replace function with this:
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;
}
Only change is && !file_exists($filename)
text added at line 98.
Save the file and again run the magento2 install command in the command prompt.
Now if you go to your browser with this URL to access Magento 2 store: http://yourname.magento.com
(In my machine, I have setup to http://sonal.magento.com/) .You will probably see a blank page like this
Here how fix this
Go to: C:\xampp\htdocs\magento2\vendor\magento\framework\View\Element\Template\File
Edit Validator.php using a text editor and find this line:
$realPath = $this->fileDriver->getRealPath($path);
Replace with this code:
$realPath = str_replace('\\', '/', $this->fileDriver->getRealPath($path));