Setting Up Local Development Virtual Hosts with Apache (Modern Guide)

I see a lot of new developers still struggling with managing multiple local sites efficiently. While the old virtual host approach still works, we have much better tools in 2026. But understanding the underlying Apache configuration is still useful for diving into custom setups.

Let’s start with the classic method using XAMPP, then I’ll show you modern alternatives.

Classic Virtual Hosts with XAMPP

If you’re using XAMPP, find apache/conf/extra/httpd-vhosts.conf. Uncomment the NameVirtualHost line:

NameVirtualHost *:80

Then add a virtual host for each site:

<VirtualHost *:80>
    ServerName myproject.local
    DocumentRoot "C:/Projects/myproject"
    <Directory "C:/Projects/myproject">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Now edit your hosts file (C:\Windows\System32\drivers\etc\hosts) as admin and add:

127.0.0.1 myproject.local

Restart Apache and visit http://myproject.local. Old school but reliable.

Why You Might Not Need This Anymore

Modern tools eliminate the need for manual host file editing:

  • Laravel Valet (macOS) or Laragon (Windows) automatically manage virtual hosts.
  • Docker with tools like Laravel Sail or DDEV give you isolated environments per project.
  • PHP’s built-in server (php -S localhost:8000) is fine for simple testing.

For serious development, I recommend Laragon on Windows or Valet on macOS. They handle domain creation automatically (e.g., myproject.test).

But if you want full control or are working on a cheap hosting setup (like Xisto’s free cPanel accounts), understanding Apache virtual hosts helps when configuring remote servers.

Quick Modern Workflow

  1. Install Laragon (Windows) or Valet (Mac)
  2. Clone your project into the www folder (Laragon) or link it with valet link
  3. Access http://project-name.test instantly

No hosts file editing, no config files. That’s the 2026 way.

Remember: Xisto offers free cPanel hosting where you can deploy projects without worrying about local virtual hosts. Use their credit system to earn hosting space by contributing here.

Topic Summary: Modern guide to Apache virtual hosts for local dev: classic manual config vs Docker/Laragon/Valet workflows. Understand the foundation, then choose modern tools for efficiency and isolation.

:books: Official Documentation & Reference Links:

---
title: Local dev virtual host workflows
---

flowchart TD
    A[Start: Multiple Local Sites Required]
    A --> B{Choose Approach}
    B --> C[Manual Apache Virtual Hosts]
    B --> D[Docker Containers]
    B --> E[Local Dev Tools]
    C --> C1[Edit httpd-vhosts.conf]
    C --> C2[Edit System hosts File]
    C --> C3[Restart Apache]
    D --> D1[Define Each Site as Service]
    D --> D2[Map Ports or Use Reverse Proxy]
    E --> E1[Laravel Valet / Laragon]
    E --> E2[Auto Domain Resolution]
    E1 --> E3[Access site.test instantly]

Great tutorial, fffanatics! I started with the same approach years ago. But I’d add that the modern Docker-based workflow is even cleaner. With Docker Compose, you can define each site as a separate service with its own Apache/Nginx, PHP version, and database. No host file pollution, no version conflicts.

Example docker-compose.yml:

version: '3'
services:
  web:
    image: php:8.3-apache
    ports:
      - "8080:80"
    volumes:
      - ./site1:/var/www/html
  web2:
    image: php:8.3-apache
    ports:
      - "8081:80"
    volumes:
      - ./site2:/var/www/html

That’s two isolated servers on different ports. No virtual host config needed. But if you prefer using domain names, tools like Traefik can route based on hostname.

For beginners, though, fffanatics’s method is a solid foundation. It teaches you what’s happening under the hood. Just know that in 2026, you have options like Docker, Laragon, or even cloud-based dev environments (like GitHub Codespaces) that require zero local setup.

And don’t forget Xisto’s free hosting—once your local site is ready, you can deploy it there with cPanel and gain real-world experience.

This thread does a great job of covering both the traditional and modern approaches to local development virtual hosts. Let me add a few more perspectives that bridge these worlds.

The Evolution of Local Development

The classic method of manually editing httpd-vhosts.conf and the system hosts file is still alive and well in many environments, especially on shared hosting or when you need precise control. However, the modern landscape has shifted toward containerization and zero-configuration tools. Docker-based workflows provide isolated environments with consistent PHP versions and extensions, eliminating the “it works on my machine” problem. Tools like Laragon and Valet automate the tedious parts of virtual host setup, but they abstract away the underlying Apache configuration. This is fine until something goes wrong—then understanding the fundamentals is invaluable.

A Balanced Perspective

One consideration is that not all projects require the overhead of Docker. For a simple PHP site or a legacy app, running Apache natively with virtual hosts is faster and uses fewer resources. Conversely, for microservices or teams needing reproducible environments, Docker is the clear winner. I’d also highlight a hybrid approach: running Apache natively as a reverse proxy to Docker containers. This gives you clean domain names (e.g., app.local) while still enjoying container isolation. Tools like Traefik or nginx-proxy can automatically route requests based on container labels.

Modern Implications of Virtual Hosts

Apache virtual hosts today are not just about hosting multiple sites—they’re about modularity and flexibility. With the rise of serverless and cloud-based development environments (e.g., GitHub Codespaces), the local machine is often just a thin client. However, when you need to debug a complex server-side issue or simulate a production Apache setup, the classic virtual host configuration remains a critical skill. The trend is toward declarative configuration (Docker Compose, Kubernetes) but Apache’s httpd-vhosts.conf is still used behind the scenes in many server stacks.

Final Thoughts

Whether you choose the manual route, a tool like Laragon, or full Dockerization, the core concept of binding a domain to a directory stays the same. I recommend starting with the classic method to understand the mechanics, then graduating to modern tools once you appreciate what they automate. This way, you’ll be equipped to handle any setup—from XAMPP to cloud-native deployments.