Linux, Web Server & Database
Configure Apache Virtual Host
Set up a correctly configured Apache virtual host for your domain.
The Problem
Apache is installed but your domain either shows the default page, the wrong site, or an error — because the virtual host for your specific domain isn't set up correctly, or the site hasn't been enabled.
About this problem
Apache uses virtual hosts to decide which site to serve for a given domain, and a common gap is creating the virtual host file but forgetting to enable it with a2ensite, or getting the ServerName/DocumentRoot mismatched against where the actual files live.
This comes up constantly when adding a new domain to a server that already hosts other sites, or when following outdated instructions that don't match the current Apache version's layout.
What's Included
- Creating a correctly configured virtual host for your specific domain
- Setting the correct DocumentRoot and enabling necessary directory permissions
- Enabling the site and reloading Apache correctly
- Testing that the domain resolves to the correct content without affecting other sites
What's NOT Included
- SSL certificate setup for the new domain (see the Let's Encrypt service)
- DNS configuration pointing the domain at this server (separate service if needed)
- Resolving conflicts caused by a deliberately non-standard existing Apache setup
How It Works
- Create a virtual host file with the correct ServerName and DocumentRoot.
- Set Directory permissions and AllowOverride as the application requires.
- Enable the site with a2ensite and disable any conflicting default site if necessary.
- Test the configuration with apachectl configtest before reloading.
- Verify the domain serves the correct content and other existing sites remain unaffected.
In practice: you buy the service, send over whatever access or details the job needs, I investigate and do the work, and you confirm it's resolved before we call it done.
Frequently Asked Questions
- Why isn't my new Apache site showing up?
- Most commonly the virtual host file was created but never enabled with a2ensite, or Apache was never reloaded after the change — both are easy to forget.
- What's the difference between sites-available and sites-enabled?
- sites-available holds all virtual host config files whether active or not; sites-enabled contains symlinks to the ones actually active — a2ensite creates that symlink for you.
- Can I run multiple domains on the same Apache server?
- Yes, each with its own virtual host block specifying a unique ServerName and DocumentRoot, all served from the same Apache instance.
- Why do I get a 403 Forbidden error on my new virtual host?
- Usually a permissions issue on the DocumentRoot directory, or a Directory block in the virtual host that doesn't grant the access the application needs.
- Do I need to restart or reload Apache after adding a virtual host?
- A reload is sufficient and doesn't drop active connections, whereas a full restart briefly stops the service — reload is preferred unless a specific change requires a restart.
- How do I check which virtual host is actually being used for a domain?
- apachectl -S lists all configured virtual hosts and which one matches each ServerName, useful for spotting conflicts between multiple sites.