1. Install the XAMPP installation package to the D drive. After the installation is completed, exit the XAMPP integrated environment and enter the next step to configure the virtual host; first create a new directory magento2 and test folder in the XAMPP/htdocs directory (this folder is your project all content).
PS. When creating multiple virtual hosts, you also need to create a new folder to contain all the contents of your project such as magento2 and test. If you need to create more, create the corresponding folder.
2. Find your XAMPP installation directory and open the following directories in order: apache/conf/extra directory. Find the httpd-vhosts.conf file and open it with Notepad.
3. After opening http-vhosts.conf, add the following code at the bottom:
<code><VirtualHost *:80> ServerName www.magento2.com DocumentRoot "D:/XAMPP/htdocs/magento2" <Directory "D:/XAMPP/htdocs/magento2"> Options FollowSymLinks IncludesNOEXEC Indexes DirectoryIndex index.html index.htm index.php AllowOverride all Order Deny,Allow Allow from all Require all granted </Directory> </VirtualHost> <VirtualHost *:80> ServerName www.test.com DocumentRoot "D:/XAMPP/htdocs/test" <Directory "D:/XAMPP/htdocs/test"> Options FollowSymLinks IncludesNOEXEC Indexes DirectoryIndex index.html index.htm index.php AllowOverride all Order Deny,Allow Allow from all Require all granted </Directory> </VirtualHost> </code>
4. In addition, you need to configure the C drive host file and find the following directories in sequence: C drive/windows/system32/drivers/etc directory , find the hosts file, open it with Notepad, add 127.0.0.1 www.magento2.com and save it, such as:
<code>127.0.0.1 www.magento2.com 127.0.0.1 www.test.com</code>
5. After configuring the virtual host, restart the XAMPP integrated environment.
The above introduces the specific steps of configuring a virtual host in XAMPP, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.