How to use the Apache VirtualHost Generator
- Pick the scenario: static site, WordPress (pretty permalinks and .htaccess support), PHP-FPM or a reverse proxy to an app on a port.
- Enter your domain, the document root or upstream address and how
wwwshould be handled. - Tick the extras — HTTPS, HTTP/2, compression, caching, security headers, WebSockets.
- Save the config in
/etc/apache2/sites-available/and run the enable commands — they include the modules it needs.
VirtualHost vs .htaccess
A VirtualHost lives in the server config and is read once when Apache starts, so it is faster and can do things .htaccess can’t, like listening on ports, SSL certificates and proxying. Use .htaccess only when you can’t edit the server config (shared hosting) — the .htaccess Generator covers that case.
Modules the config uses
| Option | Module |
|---|---|
| HTTPS redirect, www redirect, WordPress | mod_rewrite |
| HTTPS | mod_ssl |
| HTTP/2 | mod_http2 (needs the event or worker MPM, which PHP-FPM setups use) |
| Reverse proxy / WebSockets | mod_proxy, mod_proxy_http, mod_proxy_wstunnel |
| PHP-FPM | mod_proxy_fcgi |
| Compression, caching, headers | mod_deflate, mod_expires, mod_headers |
Check the syntax with sudo apachectl configtest before reloading. Prefer Nginx or Caddy? See the Nginx Config Generator and Caddyfile Generator.
Also searched as: apache vhost config, apache reverse proxy config, apache virtual host example, apache ssl virtualhost, apache wordpress config, apache2 site config, apache https redirect.
Tools that pair well with the Apache VirtualHost Generator
- YAML Validator — Paste a Docker Compose file, Kubernetes manifest, GitHub Actions workflow or any YAML to pinpoint errors, catch common pitfalls and get a cleanly formatted version.
- Kubernetes YAML Generator — Fill in your app’s name, image and port and get production-ready Kubernetes YAML: a Deployment with probes, resource limits and a hardened security context, plus the Service, Ingress with TLS, ConfigMap, Secret and HorizontalPodAutoscaler you tick — in one file ready for kubectl apply.
- systemd Service Generator — Run your app as a proper Linux service that starts on boot and restarts when it crashes.
- GitLab CI Generator — Pick your stack and get a working .gitlab-ci.yml: install with caching, lint and test jobs, a build with artifacts, a Docker image pushed to the GitLab registry, or a GitLab Pages deploy — with rules that run pipelines for merge requests and your default branch without duplicates.