Apache Config Generator
Create a virtual host file for Apache 2.4 from a short form. The result covers the HTTP to HTTPS redirect, the document root with correct permissions, PHP through PHP-FPM or a proxied application, and lists exactly which modules to enable and which commands to run.
- Runs in your browser
- No sign-up
- Free to use
How to install it
How to use Apache Config Generator
- Enter the domain and decide whether www should be answered too.
- Choose what the site runs and enter the document root or the app address.
- Select the HTTPS setup and the options you want.
- Download the file and follow the installation steps beside it.
Apache Config Generator features
Complete virtual hosts
A port 80 block that redirects and a port 443 block that serves, each with ServerName and aliases.
PHP-FPM or mod_php
A SetHandler block for PHP-FPM through a Unix socket, or plain mod_php.
Reverse proxy
ProxyPass with preserved host, forwarded protocol and optional WebSocket support.
Directory rules
No directory listings, explicit access grant, .htaccess allowed or ignored, optional front controller.
Module list
Tells you which modules the file needs, as an a2enmod command.
HTTPS options
Let's Encrypt or custom certificate paths, modern protocols only, HTTP/2 and optional HSTS.
When to use Apache Config Generator
- Adding a new site to an Apache server.
- Running a Node.js, Django or Go app behind Apache.
- Moving rules out of .htaccess into the server configuration for speed.
- Switching a site from mod_php to PHP-FPM.
Apache Config Generator FAQ
How is this different from the .htaccess Generator?
An .htaccess file changes behaviour for one folder and can be used on shared hosting without server access. A virtual host file defines the site itself, its domain, root folder, certificate and logs, and requires access to the server configuration. On your own server, the virtual host is the right place for most rules.
Where do I save the file?
On Debian and Ubuntu: /etc/apache2/sites-available/, then a2ensite and a reload. On RHEL-family systems: /etc/httpd/conf.d/, then restart httpd. The installation steps next to the output show the commands.
What does AllowOverride do?
It decides whether Apache reads .htaccess files in the site's folders. “All” is required by applications that ship their rules in .htaccess, such as WordPress. “None” makes Apache skip the lookup on every request, which is faster, but then all rules have to be written in the virtual host.
Why “Require all granted”?
Apache 2.4 denies access to the file system by default. Each document root needs an explicit grant in a Directory block. Its absence is the usual cause of a 403 Forbidden on a freshly configured site.
mod_php or PHP-FPM?
mod_php runs PHP inside every Apache process and forces the older prefork mode. PHP-FPM runs PHP in its own pool of processes, lets Apache use the faster event mode and HTTP/2, and can run different sites as different users. PHP-FPM is the recommended choice today.
Does it work with XAMPP or on Windows?
The VirtualHost syntax is the same. Paths differ: use your drive paths for DocumentRoot, and add the block to apache\conf\extra\httpd-vhosts.conf. The a2enmod commands do not exist there; modules are enabled by uncommenting LoadModule lines in httpd.conf.
Virtual hosts in Apache
One Apache server can host many websites. Each is described by a VirtualHost block that states which address and port it listens on and which host names it answers for. When a request arrives, Apache compares the Host header with the ServerName and ServerAlias of each virtual host on that port and uses the first match; if none matches, the first virtual host defined for that port serves as the default. Getting ServerName right is therefore the heart of the configuration.
HTTPS sites need two blocks. The one on port 80 has a single purpose, redirecting to the secure address. The one on port 443 holds the certificate and everything else. Keeping them separate avoids the conditional redirect rules that are a common source of loops, and makes it obvious where each directive applies.
Inside the virtual host, Directory blocks control access to the file system. Apache 2.4 uses the Require directive: “Require all granted” opens a folder to visitors and “Require all denied” closes it. Options controls features such as directory listings, and AllowOverride controls .htaccess. A sensible default is to grant access to the document root only, switch listings off and deny hidden files.
Apache is modular, and many directives exist only when their module is loaded. SSLEngine needs mod_ssl, RewriteRule needs mod_rewrite, ProxyPass needs mod_proxy and mod_proxy_http, Header needs mod_headers. A configuration that uses a directive from a module that is not enabled fails the syntax test with “Invalid command”. That is why the generator lists the modules alongside the file, and why “apachectl configtest” should always be run before a reload.