Free Online Apache Virtual Host Generator
Generate Apache virtual host configurations for HTTP and HTTPS.
Generated for Apache 2.4. Run apachectl configtest before reloading the service.
About the Apache Virtual Host Generator
A virtual host tells Apache which files, logs, certificates, and PHP handler belong to a domain. Writing one by
hand is repetitive, and small differences between the HTTP and HTTPS versions can cause redirect loops, missing
certificate warnings, or PHP files served as plain text. This generator builds a matched pair of virtual host
blocks from a short form and produces a configuration file ready to place in sites-available.
The HTTP block can either serve the site directly or redirect every request to its HTTPS equivalent. Redirecting is the usual choice for public sites: it keeps one canonical URL, avoids duplicate content, and ensures cookies marked secure are only sent over TLS. When the redirect is enabled, the HTTP block contains a permanent redirect and log directives. When it is disabled, both blocks share the same document root and PHP handler so the site works on either scheme. The generated certificate paths follow the common Let's Encrypt layout, but you can replace them with any absolute path on your server.
The HTTPS block enables SSLEngine, points to the certificate and key, and optionally adds a strict
transport security header. HSTS tells browsers to use HTTPS for future visits, so only enable it after the
certificate and redirect are confirmed working. If a PHP-FPM socket is supplied, the tool adds a
FilesMatch section that sends .php requests to that socket through
mod_proxy_fcgi. This requires proxy and proxy_fcgi to be enabled. Leave the
socket blank for static sites or when PHP runs through a different mechanism.
Directory options use Apache 2.4 syntax. AllowOverride All lets .htaccess files work,
which many frameworks need but which adds per-request file checks; set it to None if you keep all
configuration in the vhost. Directory listing is disabled by default with Options -Indexes. Log
paths combine the configured log directory with the domain name. After copying the file, enable the site, run a
configuration test, and reload Apache. The generator does not install certificates, create directories, or touch
a live server.
How to use this tool
- Enter the primary domain, aliases, document root, and log directory.
- Set the certificate and key paths, and optionally the PHP-FPM socket.
- Choose redirect, HSTS, and directory-listing options, then click Generate.
- Copy the result or download it as a
.conffile for Apache.
Frequently asked questions
Which Apache version does this target?
The output uses Apache 2.4 directives such as Require all granted. Apache 2.2 used Order and Allow instead and is not supported.
Why do I need both a certificate and a key?
Apache needs the public certificate chain and the matching private key to terminate TLS. The generator does not validate that the files exist or match.
Can I use this with Nginx?
No. Nginx uses a different configuration format. This tool produces Apache virtual host blocks only.