---
name: "dh_apache2"
section: "1"
platform: "linux"
package: "apache2-dev"
version: "2.4.68-1~deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/dh_apache2"
---

# dh\_apache2(1)

register configuration snippets to the Apache web server

## NAME

dh\_apache2 - register configuration snippets to the Apache web server

## SYNOPSIS

**dh\_apache2** \[*debhelper options*\] \[**--conditional**=*expression*\] \[**--error-handler=***function*\] \[**-n**\|**--noscripts**\]\
     \[**-e**\|**--noenable**\] \[**-r**\|**--restart**\]

## DESCRIPTION

**dh\_apache2** is a debhelper program that is responsible for correctly installing Apache2 configuration snippets and setting postinst, prerm and dependencies in Apache2 web server modules and web applications.

It supports the following configuration types

- •

  Apache2 modules

- •

  Apache2 configuration snippets for web applications

- •

  Apache2 sites

**dh\_apache2** supports two modes: A limited auto-configuration heuristic or alternatively a configuration file driven approach. If a file named debian/package.apache2 exists, actual actions are determined by that file.

## OPERATION MODES

**dh\_apache2** can be used in two modes: A configuration file driven approach and a heuristic approach. The configuration driven mode is fully documented in the **FILES** section below. This mode is activated by supplying a [**debhelper**(7)](/debhelper/7.md) configuration file (e.g. debian/*package*.apache2).

The alternative is a heuristic mode, in which no files are installed through **dh\_apache2**. Instead the helper will scan the package installation directory for recognized files and guess their purpose depending on their installation path in the file system. Use with caution.

## INVOCATION

**dh\_apache2** is not part of debhelper and might require information available in the apache2-dev package. Packages making use of **dh\_apache2** should declare a build-dependency against the virtual **dh-apache2** package.

**dh\_apache2** supports both, called directly from a debian/rules file or as [**dh**(1)](/dh/1.md) addon. In the former case the helper should run after [**dh\_install**(1)](/dh_install/1.md) or their respective counter parts in local implementations at earliest. Alternatively it can be used as dh addon by invoking it with

```
  %:
     dh $@ --with apache2
```

## FILES

- debian/*package*.apache2

  - debian/apache2

  Lists files to be registered with the Apache 2 HTTP server. The file is interpreted as line separated list of installation stanzas, where each entry consists of whitespace separated values conforming to the file semantics below.

### FILE SEMANTICS

Each line consists of a triple

*type* *file* \[*arguments*\]

where the values are interpreted as follows:

*type*

Denotes the type of file to be installed. Recognized values are **conf** for Apache2 global configuration snippets, **site** for virtual host configurations and **mod** for Apache2 modules.

*file*

Is interpreted as existing file name within the source package. No path expansion is effectuated. Just like [**dh\_install**(1)](/dh_install/1.md), **dh\_apache2** can not rename files.

*arguments*

Is inrerpreted as optional arguments if any, currently used by **conf** stanzas only

### GLOBAL CONFIGURATION FILES

Global configuration files (determined by the **conf** type) must have a *.conf* suffix and are installed to */etc/apache2/conf-available*. Moreover, the configuration is activated in the maintainer script at installation time.

Such global configuration snippets are supposed to be used by web applications. Such stanzas accept an optional third *arguments* which is interpreted as dependency line of alternative web servers the package supports. See *EXAMPLES* below.

**dh\_apache2** will set dependencies in **${misc:Recommends}** accordingly when this type of configuration is found. Alternatives from the optional *argument* is incorporated into this dependency line.

### SITE CONFIGURATION FILES

Site configuration files (determined by the **site** type) must have a *.conf* suffix and are installed to */etc/apache2/sites-available*. Moreover, the configuration is activated in the maintainer script at installation time.

Such global configuration snippets are supposed to be used by web applications and third party packages which install virtual host configurations. This type of configuration sets the same dependencies as configuration files.

### MODULES

Modules are handled specially and are determined by the **mod** type. Modules can either have a *.conf* or *.load* suffix. In that case the file is interpreted as module load file or module configuration file respectively and is nstalled to */etc/apache2/mods-available*. If the file is ending with a *.so* suffix it is interpreted as actual module shared object and is installed to the Apache module directory. Moreover, if a *.load* file is installed the configuration is activated in the maintainer script at installation time.

A typical module configuration has two lines, one for the *.load* file, and one for the *.so* file, albeit the latter could be installed by upstream's makefile, too.

**dh\_apache2** will set dependencies in **${misc:Depends}** accordingly when this type of configuration is found.

## OPTIONS

- **--error-handler=***function*

  Call the named shell *function* if running the maintainer script fails. The function should be provided in the *prerm* and *postinst* scripts, before the **#DEBHELPER#** token.

- **--conditional**=*function*

  Only execute maintainer scripts if the named shell *function* evaluates to a true value at installation time. This is useful to web applications which want to install Apache configuration files depending on a user input, for example if they interface to the user through [**debconf**(1)](/debconf/1.md).

  The defaults is to always execute the scripts. The named function should be provided in the *prerm*, *postrm* and *postinst* scripts, before the **#DEBHELPER#** token.

- **--restart** **-r**

  In maintainer scripts, do not try to reload the web server, but restart it. Otherwise the default action is used, which means global configuration and sites make the web server to be reloaded on success, modules are restarted.

- **-e**, **--noenable**

  Install maintainer scripts accordingly, but do not enable the scripts or configuration by default.

- **-n**, **--noscripts**

  Do not modify *postinst*/*postrm*/*prerm* maintainer scripts.

## NOTES

Note that this command is not idempotent. [**dh\_prep**(1)](/dh_prep/1.md) should be called between invocations of this command. Otherwise, it may cause multiple instances of the same text to be added to maintainer scripts.

## EXAMPLES

The examples below lists valid entries for a debian/*package*.apache2 file. For example, the two lines below install a fictional *mod\_foo* Apache module along a Debian specific *.load* file:

```
 mod src/foo/mod_foo.so
 mod debian/foo.load
```

The example below installs a fictional web application called phpmyfoo supplied in a package which also supports Lighttpd and nginx:

```
 conf debian/phpmyfoo.conf lighttpd (>= 1.4.30) | nginx-full
```

Or, the same example again this time without support for other web servers:

```
 conf debian/phpmyfoo.conf
```

As a final example, install a module called *mod\_foo* along with a site configuration for a fictional site configuration for the site *example.com*:

```
 mod  src/foo/mod_foo.so
 mod  debian/foo.load
 mod  debian/foo.conf
 site debian/example_com.conf
```

## SEE ALSO

[apache2ctl(8)](/apache2ctl/8.md), a2query(8), [debhelper(7)](/debhelper/7.md), [dh(1)](/dh/1.md)

## AUTHOR

This manual and dh\_apache2 was written by Arno Toell \<debian@toell.net\>.
