Best practices for packaging Apache HTTPD modules

This is for Debian Squeeze and Wheezy. For Jessie, look here

Meta-data

Configuration

Security considerations

Maintainer scripts

Safe version

The safe way is to always restart Apache.

postinst
execute on install / upgrade

   if [ "$1" = configure ] ; then
       # only enable on new installs, not on upgrades
       if [ -z "$2" ] ; then
           a2enmod -q something
       fi
       # only restart if mod_something is enabled
       if [ -e /etc/apache2/mods-enabled/something.load ] ; then
           invoke-rc.d apache2 restart
       fi
   fi
prerm
execute on removal

   if [ "$1" = remove ] ; then
       a2dismod -q -f something || true
       invoke-rc.d apache2 restart
   fi

Advanced version

For some modules and in some cases, it is enough to do a reload instead of a restart. If you want to do this, be sure to actually test that

For some modules, reload works for upgrades but not install/remove. For some modules reload never works.

Other things