Skip to content
Development repository for the apache2 cookbook
Ruby HTML Perl
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci mod-ssl resource and testing (#589) Feb 20, 2019
.delivery Add delivery config Jul 6, 2017
.github fix codeowners to use @ mention Jun 19, 2019
documentation Permit overwriting cookbook for apache2_mod templates (#642) Aug 7, 2019
files Remove welcome.conf Jan 3, 2019
libraries Remove recipes (#611) Mar 5, 2019
resources Permit overwriting cookbook for apache2_mod templates (#642) Aug 7, 2019
spec Remove recipes (#611) Mar 5, 2019
templates mod info arguments type consistency with mod-status (#625) May 20, 2019
test remove test change Jun 21, 2019
.envrc mod-ssl resource and testing (#589) Feb 20, 2019
.gitignore Use the default cookbook style rules Feb 21, 2017
.kitchen.dokken.yml Accept Chef License (#634) May 13, 2019
.kitchen.yml resource/install.rb: Auto-convert the listen property to an Array whe… May 21, 2019
.mdlrc mod-ssl resource and testing (#589) Feb 20, 2019
.rubocop.yml mod-ssl resource and testing (#589) Feb 20, 2019
Berksfile Install resource Nov 15, 2018 mod-ssl resource and testing (#589) Feb 20, 2019 Release 7.1.1 Aug 7, 2019 CODE_OF_CONDUCT: add Feb 27, 2017 mod-ssl resource and testing (#589) Feb 20, 2019
Dangerfile standardise dangerfile (#631) May 9, 2019
Gemfile Install resource Nov 15, 2018
LICENSE LICENSE: rename from LICENSE.txt Feb 27, 2017 Readme Maintainers May 12, 2019 Correct a small typo (#618) Apr 9, 2019 markdown lint fixes Mar 28, 2019
chefignore Updte chefignore Feb 20, 2019
metadata.rb Release 7.1.1 Aug 7, 2019

apache2 Cookbook

Cookbook Version Build Status OpenCollective OpenCollective License

This cookbook provides a complete Debian/Ubuntu style Apache HTTPD configuration. Non-Debian based distributions such as Red Hat/CentOS, ArchLinux and others supported by this cookbook will have a configuration that mimics Debian/Ubuntu style as it is easier to manage with Chef.

Debian-style Apache configuration uses scripts to manage modules and sites (vhosts). The scripts are:

  • a2ensite
  • a2dissite
  • a2enmod
  • a2dismod
  • a2enconf
  • a2disconf

This cookbook ships with templates of these scripts for non-Debian based platforms.


This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of Chef cookbook maintainers working together to maintain important cookbooks. If you’d like to know more please visit or come chat with us on the Chef Community Slack in #sous-chefs.


Depending on your OS configuration and security policy, you may need additional recipes or cookbooks for this cookbook's recipes to converge on the node. In particular, the following Operating System settings may affect the behavior of this cookbook:

  • SELinux enabled
  • Firewalls (such as iptables, ufw, etc.)
  • Compile tools
  • 3rd party repositories

On RHEL, SELinux is enabled by default. The selinux cookbook contains a permissive recipe that can be used to set SELinux to "Permissive" state. Otherwise, additional recipes need to be created by the user to address SELinux permissions.

To deal with firewalls Chef Software does provide an iptables and ufw cookbook but is migrating from the approach used there to a more robust solution utilizing the general firewall cookbook to setup rules. See those cookbooks' READMEs for documentation.

On ArchLinux, if you are using the apache2::mod_auth_openid recipe, you also need the pacman cookbook for the pacman_aur LWRP. Put recipe[pacman] on the node's expanded run list (on the node or in a role). This is not an explicit dependency because it is only required for this single recipe and platform; the pacman default recipe performs pacman -Sy to keep pacman's package cache updated.


The following platforms and versions are tested and supported using test-kitchen

  • Ubuntu 16.04 / 18.04
  • Debian 8/9
  • CentOS 7+
  • Fedora Latest
  • OpenSUSE Leap

Notes for RHEL Family

Apache2.4 support for Centos 6 is not officially supported.


It is recommended to create a project or organization specific wrapper cookbook and add the desired custom resources to the run list of a node. Depending on your environment, you may have multiple roles that use different recipes from this cookbook. Adjust any attributes as desired.

# service['apache2'] is defined in the apache2_default_install resource but other resources are currently unable to reference it.  To work around this issue, define the following helper in your cookbook:
service 'apache2' do
  extend Apache2::Cookbook::Helpers
  service_name lazy { apache_platform_service_name }
  supports restart: true, status: true, reload: true
  action :nothing

apache2_install 'default_install'
apache2_module 'headers'
apache2_module 'ssl'

apache2_default_site 'foo' do
  default_site_name 'my_site'
  cookbook 'my_cookbook'
  port '443'
  template_source 'my_site.conf.erb'
  action :enable

Example wrapper cookbooks: basic site ssl site



This project exists thanks to all the people who contribute.


Thank you to all our backers!


Support this project by becoming a sponsor. Your logo will show up here with a link to your website.

You can’t perform that action at this time.