Open-source project
h5bp/server-configs-apache avatar
h5bp/server-configs-apache

Apache Server Configs: A Reference Kit for Hardening httpd Without Guesswork

GitHub describes it as Apache HTTP server boilerplate configs. The repository metadata lists Shell as its primary language. The metadata lists the MIT license. This article stays within the project description and details documented in the GitHub repository README.

3,246 stars619 forksShellMIT

At a glance

What is it?
A review of the h5bp/server-configs-apache repository, a set of MIT-licensed Apache configuration snippets for performance, security, and correct content types. It serves as a reference and a drop-in template, but it demands careful module management and a clear understanding of your hosting environment.
Who is it for?
Adopt Apache Server Configs if you manage your own httpd.conf or have access to .htaccess and want a battle-tested set of rules for caching, compression, and security headers. Avoid it if you prefer a minimal configuration or run a hosting environment where you cannot enable required modules like mod_rewrite or mod_headers.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 123 days ago.
What is it written in?
Mainly Shell, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 14, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • h5bp/server-configs-apache3,246 ★ · -2
Star history
Repository2026-08-132026-11-14
h5bp/server-configs-apache3.2k3.2k

-2 Stars in the last 93 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

What This Repository Actually Provides

The h5bp/server-configs-apache repository is a collection of Apache HTTP Server configuration snippets. It targets a specific problem: most default Apache installations serve content with suboptimal caching headers, weak compression settings, and missing security protections. The project assembles a set of rules that address these issues, saving you from writing each directive from scratch. It is intended for system administrators and developers who run their own Apache instances or who have enough hosting control to use .htaccess files. The README positions it as a boilerplate, not a turnkey product. You are expected to adapt the snippets to your environment. The repository's primary language is Shell, because it includes scripts for enabling modules and managing sites, but the core value is in the .conf files.

The Two Paths to Using It: httpd.conf vs .htaccess

The README presents two distinct deployment routes. The first assumes you have access to the main server configuration file, usually httpd.conf. This is the recommended approach, and the README explicitly notes that using .htaccess files slows down Apache. The second path is for shared hosting environments where you cannot touch the main configuration. In that case, you use an .htaccess file, and the repository includes a guide for that. This distinction matters because the performance impact of .htaccess is real: Apache re-parses these files on every request, adding overhead. If you have full control, you should avoid that route. The repository's structure reflects this: it includes a full httpd.conf and a separate set of snippets that can be included from either context.

Repository Structure: Mixins, Vhosts, and a Main Config

The layout is simple but deliberate. The h5bp/ directory contains config snippets, which the README calls mixins. There are individual snippets for specific features, plus combined files like basic.conf that bundle a recommended subset. The basic.conf file adds expires headers, allows cross-domain fonts, and protects system files from web access. The vhosts/ directory holds virtual host definitions, with a templates/ subfolder containing example.com.conf templates for secure and non-secure hosts. You copy these templates and replace example.com with your actual hostname. The httpd.conf file at the root is the main configuration file, designed to be used directly if you replace your existing httpd.conf. The README suggests that all files in vhosts/ are loaded automatically, except those with dot prefixes or non-.conf extensions. This naming convention gives you a way to stage sites: prefix with a dot to disable, then rename to enable.

Getting It Running: Commands and Module Requirements

The README gives concrete commands for testing and reloading Apache. To verify the configuration, run apache2 -t. If you have a custom config file, use apache2 -t -f httpd.conf. To apply changes, run apache2ctl reload. For a standard apt-get installation, you enable required modules with sudo a2enmod setenvif headers deflate filter expires rewrite include, then restart with sudo /etc/init.d/apache2 restart. For MAMP, WAMP, or XAMPP, the README points to specific httpd.conf paths and tells you to uncomment module lines. The module list is long: autoindex, deflate, expires, filter, headers, include, mime, rewrite, and setenvif. This is a critical point. If any of these modules is missing, some rules will silently fail or cause errors. The README warns that some configurations won't have any effect unless the appropriate modules are enabled. You must check this before adopting the configs.

The Trade-Off: Comprehensive Rules vs. Operational Overhead

The repository's strength is also its weakness. It provides a large set of rules, but that means you inherit a lot of directives, many of which you may not need. For example, the README mentions protecting system files from web access. That is useful, but if your application already handles that, the rule is redundant. More importantly, the dependency on multiple modules increases the surface for misconfiguration. If you run a minimal Apache setup for a small site, this boilerplate might be overkill. The README offers basic.conf as a lighter option, but even that requires several modules. The project assumes you are willing to manage a complex configuration. If you prefer a lean server, you might be better off writing a few custom directives. The trade-off is between convenience and control. The repository gives you a tested starting point, but you must review every rule and decide whether it applies to your use case.

A Real Alternative: Manual Configuration or Other H5BP Projects

The obvious alternative is to write your own Apache configuration from scratch. This gives you full control and avoids the module dependency burden. You can add only the headers and caching rules you need. However, that requires knowing the exact directives and their syntax. Another alternative is to use the Nginx version of these configs, h5bp/server-configs-nginx, if you are open to switching servers. The approach differs fundamentally: Nginx does not support .htaccess, so you must configure everything in the main server block. That forces a more centralized setup, which can be cleaner but less flexible for shared hosting. The choice between Apache and Nginx often depends on your existing infrastructure. If you are committed to Apache, the repository is a solid reference. If you are starting fresh, you might weigh the operational differences.

Maintenance and License: What to Expect

The repository is licensed under MIT, which means you can use, modify, and distribute the configs freely, with attribution. The last push was in December 2022, and the latest release is 6.0.0. That suggests the project is stable but not actively developed. The README does not mention a maintenance schedule or upgrade path. You should treat it as a snapshot of best practices at that time. Apache evolves, and new directives or changes to existing ones could make some rules outdated. The repository includes a test workflow, which is a good sign, but you should still run apache2 -t after any changes. The upgrade cost is low if you use the repository as a reference: you copy the snippets you need. If you use it directly by replacing your httpd.conf, you must re-apply any environment-specific edits after an upgrade. The README includes a backup step, cp -r apache2 apache2-previous, which is wise.

Editorial conclusion

Adopt Apache Server Configs if you manage your own httpd.conf or have access to .htaccess and want a battle-tested set of rules for caching, compression, and security headers. Avoid it if you prefer a minimal configuration or run a hosting environment where you cannot enable required modules like mod_rewrite or mod_headers. Before adopting, verify that your Apache version supports all included directives, check your httpd.conf paths for ServerRoot and TypesConfig, and run apache2 -t after any change. The repository's value lies in its curated snippets, not in being a one-size-fits-all server setup.

Frequently asked questions

How do I check an Apache configuration before reloading it?

Run apache2 -t to verify the running configuration, apache2 -t -f httpd.conf to verify against a specific file, then apache2ctl reload to apply it. The standalone instructions in the same page use sudo /etc/init.d/apache2 restart instead.

Which Apache modules do the h5bp server configs require?

Nine are named: autoindex, deflate, expires, filter, headers, include, mime, rewrite and setenvif. The documented command sudo a2enmod setenvif headers deflate filter expires rewrite include enables seven of them, leaving autoindex and mime out.

Where should I put the h5bp Apache configuration files?

The page names /usr/local/apache2 as the default location but says the files may sit in a variety of places depending on how the server was installed, and points at the httpd wiki page for distribution default layouts. The direct-copy example assumes /usr/local/apache2.

What does h5bp/server-configs-apache publish to npm?

A single file, dist/.htaccess, listed as the only entry in the files array of a package named apache-server-configs at version 6.0.0. The httpd.conf, the h5bp snippets and the vhosts templates are not part of that payload.

How do I add a virtual host using these Apache configs?

Copy templates/example.com.conf to a dot-prefixed name, replace the example.com placeholders with sed, then move it to the real hostname. The dot prefix keeps the file out of the loader, which loads every non-dot .conf file in vhosts automatically.

Official sources

  1. Official README
  2. Project repository
  3. Release notes
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/h5bp-server-configs-apache.svg)](https://hysenlabs.com/projects/h5bp-server-configs-apache)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/h5bp-server-configs-apache.svg)](https://hysenlabs.com/projects/h5bp-server-configs-apache)

Was this useful?