To create a virtual host (vhost) using XAMPP, you'll need to follow these steps:
Step 1: Open the Apache configuration file
- Locate the
httpd-vhosts.conf
file in the XAMPP installation directory. By default, it's located atC:\xampp\apache\conf\extra\httpd-vhosts.conf
. - Open the file in a text editor.
Step 2: Configure the virtual host
Add the following code at the end of the file to define your virtual host:
<VirtualHost *:80> DocumentRoot "C:/xampp/htdocs/your_project_folder" ServerName yourdomain.test </VirtualHost>
Replace
"C:/xampp/htdocs/your_project_folder"
with the actual path to your project folder. This is the directory where your website's files reside. Replace"yourdomain.test"
with the desired domain name for your virtual host. You can choose any domain name, but make sure to add it to the hosts file as well (explained in the next step).
Step 3: Modify the hosts file
- Open the hosts file on your computer. It's located at
C:\Windows\System32\drivers\etc\hosts
. - Open the file in a text editor with administrative privileges.
Add the following line at the end of the file:
127.0.0.1 yourdomain.test
Replace
"yourdomain.test"
with the same domain name you used in the virtual host configuration.
Step 4: Restart Apache server
- Open the XAMPP Control Panel.
- Stop the Apache server by clicking the "Stop" button.
- Start the Apache server again by clicking the "Start" button.
- Open your web browser.
- Visit
http://yourdomain.test
(replace"yourdomain.test"
with your chosen domain name). - If everything is set up correctly, you should see your website served from the specified project folder.
- That's it! You have successfully created a virtual host using XAMPP. Now you can develop and access your website using the custom domain name you configured.
Step 5: Access your virtual host
- Log in to post comments