How to set virtual host in xampp?

Member

by gilbert , in category: Third Party Scripts , 10 days ago

How to set virtual host in xampp?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by darrion.kuhn , 9 days ago

@gilbert 

To set up a virtual host in XAMPP, follow these steps:

  1. Open the XAMPP control panel and click on the "Config" button for Apache.
  2. Select "httpd-vhosts.conf" from the list of configuration files.
  3. Add a new virtual host entry at the bottom of the file. The entry should include the following information:
1
2
3
4
5
6
7
8
9
<VirtualHost *:80>
   DocumentRoot "C:/xampp/htdocs/project_folder"
   ServerName yourdomain.local
   <Directory "C:/xampp/htdocs/project_folder">
       Options Indexes FollowSymLinks Includes ExecCGI
       AllowOverride All
       Require all granted
   </Directory>
</VirtualHost>


Replace "project_folder" with the name of your project directory and "yourdomain.local" with the desired domain name for your virtual host.

  1. Save the changes to the configuration file and close the editor.
  2. Edit the hosts file on your computer to map the domain name to the localhost IP address. The hosts file is located at C:WindowsSystem32driversetchosts on Windows or /etc/hosts on Linux and macOS.


Add the following entry to the hosts file:

1
127.0.0.1   yourdomain.local


Replace "yourdomain.local" with the domain name specified in the virtual host configuration.

  1. Restart the Apache server in XAMPP.
  2. Open your web browser and type the domain name (e.g., yourdomain.local) in the address bar to access your virtual host.


Your virtual host should now be set up and accessible through the domain name you specified in the configuration.