Apache Virtual Host Builder

Generate an Apache <VirtualHost> block from a small form.

Open tool

Overview

Fill in the basics - server name, document root, port, optional aliases, log paths - and get a syntactically valid Apache <VirtualHost> block ready to drop into sites-available/. Optional toggles for SSL, rewrite engine, directory index, and access controls cover the most common production setups.

It's for sysadmins and developers who deploy on Apache HTTP Server (httpd) and don't want to copy-paste from a half-remembered example. Reach for it when configuring a new site, migrating from a single-tenant config to name-based virtual hosts, or standing up a quick development host that mirrors prod.

How it works

A virtual host block is a container directive in Apache's configuration language. The generator emits the canonical structure: <VirtualHost *:port> opener, ServerName and optional ServerAlias, DocumentRoot, log paths via ErrorLog / CustomLog, and a nested <Directory> block for AllowOverride and Require rules. SSL hosts get matching SSLEngine on, SSLCertificateFile, and SSLCertificateKeyFile lines.

Output follows the conventions documented in the Apache 2.4 manual and the typical Debian/Ubuntu and RHEL package layouts (Listen directives live elsewhere, vhost files go in sites-available/).

Examples

  • Plain HTTP site:
    <VirtualHost *:80>
        ServerName example.com
        DocumentRoot /var/www/example
        ErrorLog ${APACHE_LOG_DIR}/example.error.log
        CustomLog ${APACHE_LOG_DIR}/example.access.log combined
    </VirtualHost>
    
  • TLS with redirect from port 80:
    <VirtualHost *:443>
        ServerName example.com
        DocumentRoot /var/www/example
        SSLEngine on
        SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
    </VirtualHost>
    
  • Reverse proxy to a backend on localhost:3000:
    ProxyPass / http://127.0.0.1:3000/
    ProxyPassReverse / http://127.0.0.1:3000/
    
  • Aliases for www. and apex:
    ServerName example.com
    ServerAlias www.example.com
    

FAQ

Where do I put the vhost file?

On Debian/Ubuntu: /etc/apache2/sites-available/yoursite.conf, then a2ensite yoursite. On RHEL/CentOS: /etc/httpd/conf.d/yoursite.conf.

Do I need a Listen directive in the vhost?

No - Listen is a server-wide directive declared in ports.conf or httpd.conf. Vhosts only declare which *:port they bind to.

Why doesn't my vhost match incoming requests?

Apache uses the first matching VirtualHost for unknown ServerName values. Either set ServerName explicitly or ensure the file you want to match is loaded first (it's usually alphabetical).

Should I use Require all granted or older Allow from all?

Require all granted (mod_authz_core) is the 2.4+ syntax. The Order / Allow / Deny form is from 2.2 and deprecated.

Try Apache Virtual Host Builder

An unhandled error has occurred. Reload ×