DEV Community

Jack Huynh
Jack Huynh

Posted on • Updated on

Setup Environments

Step 1: XAMPP and Composer

XAMPP

First of all, you need to download and install Xampp, a simple tool helps developers to create and test their applications on a local web server.

You might wanna go with PHP 8.1 since it got pretty solid support.

Image description

Next, run set up file and proceed with all steps to install Xampp. In Select Components step, make sure to select Mysql and PHP, PHPmyadmin.

Image description

Now open XAMPP and start Apache and Mysql, green color of Apache and MySQL indicates that its been started successfully.

Image description

COMPOSER

Now we need to install Composer, a tool for dependency management in PHP.

Image description

After the installation is complete, verify that Composer is installed correctly by running the following command

composer
Enter fullscreen mode Exit fullscreen mode

If the installation was successful, the command should display the version of the installed Composer.

Image description

Step 2: PHP & MySql

Enable PHP extensions

We need to install and enable all required PHP extensions to make the installation go smoothly

bcmath  ctype   curl    dom
gd  hash    iconv   intl
mbstring    openssl pdo_mysql   simplexml
soap    xsl zip ext-sockets
Enter fullscreen mode Exit fullscreen mode

Quickly open php.ini on Xampp interface with this button

Image description

[PHP]
;extension=gd
;extension=intl
;extension=soap
;extension=xsl
;extension=sockets
;extension=sodium
;extension=zip
Enter fullscreen mode Exit fullscreen mode

Remove ; from the above lines of php.ini file. Save the file.
The other extensions are enabled by default after we install Xampp, so we don’t need to include them here. Remember to save files before exiting.

Configure PHP settings

In php.ini file, search and change the following values as below

max_execution_time=18000
max_input_time=1800
memory_limit=4G
Enter fullscreen mode Exit fullscreen mode

These values will keep the installation go properly without interruption.

Finally, restart apache to apply php settings by click on apache Stop and Start button on XAMPP

Image description

Create database for Magento 2

Before we process the installation, we have to create a database for Magento 2 website to store all settings related to products, catalog, users, store configuration….

In Xampp interface, open PHPmyadmin by clicking on Admin button to open phpmyadmin

Image description

On phpmyadmin page, click on New => type database name => click on Create to create a new database. For example, I create magento2 database here

Image description

By default, Xampp does not set a password for MYSQL, so we will need to create a new root password for mysql.

On Xampp, click on Shell button to open command interface

Image description

Next, input the following command to change mysql root password

mysqladmin.exe -u root password root
Enter fullscreen mode Exit fullscreen mode

and press Enter. I put root as password.

Now, to use phpmyadmin, you will also need to enter the new password. To make phpmyadmin automatically login with your new password, Open config.inc.php , to open this file, see the screenshot below

Image description

And insert your new password here

Image description

Finally, restart apache to apply php settings by click on apache Stop and Start button on XAMPP

Step 3: Elasticsearch

Download

[Elasticsearch (https://www.elastic.co/downloads/elasticsearch)is now a required application to install Magento 2.4, the installation process will stop if there’s something wrong with Elasticsearch verification.

Next, unzip archived file at the “C:\xampp\htdocs\”

Install and Run

Go to \elasticsearch\bin

Right click on elasticsearch.bat and select run as administrator

Image description

Leave this window running on background

Image description

Set Passwords

Before we continue, we must set password for all built-in users.

Open another terminal inside C:\xampp\htdocs\elasticsearch\bin and run this command

./elasticsearch-setup-passwords.bat interactive
Enter fullscreen mode Exit fullscreen mode

Image description

If you encounter this error

write the following line in /elasticsearch/elasticsearch.yml:

xpack.security.enabled: true
Enter fullscreen mode Exit fullscreen mode

Verify

To check if Elasticsearch is running on your system, open your browser and enter the following address: http:localhost:9200. When prompted for login credentials, use root user elastic and the password you just reset.

Image description

If you see this result page => Elasticsearch is running properly

Image description

Top comments (0)