Skip to content
shellhacks.dev

Apache Virtual Host Generator

Generate an Apache VirtualHost for PHP through PHP-FPM, a reverse proxy or a static site, with an HTTP to HTTPS redirect and Let's Encrypt certificate paths.

Free · No sign-up · Your inputs stay in your browser

Input

Generate an Apache virtual host

Output

/etc/apache2/sites-available/example.com.conf

930 characters

Enable the modules first: a2enmod proxy_fcgi setenvif rewrite ssl headers http2, then a2ensite example.com and apachectl configtest before systemctl reload apache2. PHP through proxy_fcgi lets Apache run the event MPM instead of prefork, which mod_php requires.

Runs in this browser. Nothing you paste is sent to a server.

PHP-FPM instead of mod_php

mod_php embeds PHP in every Apache process and forces the prefork MPM. Handing PHP to PHP-FPM through proxy_fcgi lets Apache run the event MPM, which handles many more idle keep-alive connections with less memory, and lets PHP be restarted and tuned on its own. The mod_proxy_fcgi documentation has the details.

Enabling it

On Debian and Ubuntu, put the file in sites-available, enable the modules and the site with a2enmod and a2ensite, then run apachectl configtest before systemctl reload apache2. A reload keeps serving existing requests while it loads the new configuration.

Share

Frequently asked questions

Why does Laravel need AllowOverride All?
Laravel's public/.htaccess contains the rewrite rules for its front controller. AllowOverride All lets Apache read it; alternatively, copy the rules into the VirtualHost and set AllowOverride None, which is faster.
How do I pass the real client IP through Apache to the app?
For a proxy, ProxyPreserveHost On keeps the Host header and Apache adds X-Forwarded-For. Configure the application to trust Apache as a proxy so it reads that header.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Go deeper

Suggested reading

Keep planning

Similar tools