How to install Magento 2.4 on localhost (Xampp, Windows OS)

Step 1: Install Elasticsearch

- Download the Elasticsearch package from https://www.elastic.co/downloads/elasticsearch

- Extra the zip file into \xampp\htdocs\

Install Elasticsearch

- Run elasticsearch.bat as Administrator (The file is in \xampp\htdocs\elasticsearch-7.10.2\bin)

Install Elasticsearch

- Check the availability of Elasticsearch by URL http://127.0.0.1:9200/, it looks like below screenshot:

Install Elasticsearch

Step 2: Install Magento 2.4

- Make sure PHP extensions (in php.ini) enabled: intl, soap, sockets, xsl, sodium

- Change Validator.php, see this link https://www.polacin.com/magento2/fix-issues-when-install-magento-2-3-0-on-xampp/

- Change Gd2.php, see this link https://www.polacin.com/magento2/fixed-installation-issue-for-magento-2-3-5-p1-and-magento-2-3-5-p2-on-windows-xampp/

- Disable Magento_TwoFactorAuth (if you get an Authentication Error) by command line

- Run command line to install Magento project:

php bin/magento setup:install --base-url="http://127.0.0.1/magento-2.4.1/" --db-host="localhost" --db-name="magento_241" --db-user="root" --admin-firstname="admin" --admin-lastname="admin" --admin-email="admin@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="127.0.0.1" --elasticsearch-port=9200

Install Magento 2.4