You are here: Home / Debian GNU/Linux / Servers / Apache 2 / Ease Apache 2 server administration with a2tools

Ease Apache 2 server administration with a2tools

by Pierre-Yves Landuré last modified Feb 27, 2017 05:03

a2tools is a script written with the intent to ease and automate the daily administration of a Apache 2 server. This howto describe its installation and usage.

This howto is tested on :

  • Debian 5.0 Lenny
  • Debian 6.0 Squeeze
  • Debian 7.0 Wheezy


This howto needs :

This howto recommands :


Install the tool :

command wget "" \
    --quiet --no-check-certificate --output-document="/usr/local/bin/a2tools"
command chmod +x "/usr/local/bin/a2tools"

Introducing a2tools

The details of the tool usage is given by :

command a2tools --help

Simple Virtual Host

Create a virtual host serving a folder :

# command a2tools "" "/opt/"


Create a virtual host redirecting a domain and all of its sub-domains to another web site:

# command a2tools --template=redirect \
# --alias="*" \
# "" ""

Reverse proxy

Create a virtual host serving a web site hosted on another server (by reverse proxying) :

# command a2tools --template=reverse-proxy "" "http://domain.server.lan/"

Note : On the "domain.server.lan" host, a virtual host "" must be setup. If the "domain.server.lan" use Apache 2, apply the settings described by Get the real IP address of a visitor accessing to a Apache 2 server behind a reverse proxy.

Removal of a domain

Delete all virtual host for a domain:

# command a2tools --remove "

Secure host (HTTPS)

Any HTTPS host needs the creation of a valid SSL certificate for its domain name, as described by Create a SSL / TLS certificate on Debian.

Create a HTTPS virtual host with the --ssl='auto' option to automaticaly create a Let's Encrypt certificate:

# sudo a2tools --ssl='auto' '' '/opt/'

Create a HTTPS virtual host with the --ssl option having for argument the name of the choosen SSL certificate (generaly, the domain name of the web site), if you have an existing certificate :

# command a2tools --ssl='' '' '/opt/'

If the choosen certificate is a wildcard valid for all sub-domains, use:

# command a2tools --ssl='*' '" '/opt/'

Note: Adding an argument to the --ssl option is equivalent to use these options:

# command a2tools --ssl \
# --private-key="/etc/ssl/private/" \
# --public-key="/etc/ssl/certificates/" \
# --root-ca="/etc/ssl/roots/" \
# --chain-ca="/etc/ssl/chains/" \
#  '' '/opt/'

A missing functionnality from Internet Explorer 6 to 8 on Windows XP limits to one SSL certificate by IP address. To host many sub-domains on a same server, the use of wildcard certificates (ie. "*") is recommanded.

To host several domains on one server without errors on Internet Explorer ,use the option --bind-ip to specify the IP address linked to the choosen SSL certificate. If you own a OVH server, assign a failover IP to the server.