LinuxCommandLibrary

a2ensite

Enable Apache website configuration

TLDR

Enable a virtual host

$ sudo a2ensite [virtual_host]
copy

Don't show informative messages
$ sudo a2ensite [[-q|--quiet]] [virtual_host]
copy

SYNOPSIS

a2ensite [-q|--quiet] [-l|--list] [<sitename>]

PARAMETERS

-l, --list
    List all available sites from sites-available

-q, --quiet
    Quiet mode: suppress progress/output messages

DESCRIPTION

The a2ensite command is a helper script for Apache2 on Debian-based Linux distributions like Ubuntu. It enables a site configuration by creating a symbolic link in /etc/apache2/sites-enabled/ pointing to the site's file in /etc/apache2/sites-available/. This activates the virtual host without modifying core config files.

Site files (e.g., 000-default.conf, example.com.conf) reside in sites-available. Running a2ensite <sitename> as root links it to sites-enabled, making Apache load it on startup or reload. If already enabled or missing, it reports accordingly.

Use -l to list available sites. After enabling, reload Apache with systemctl reload apache2 or apache2ctl graceful to apply changes without downtime. This modular system simplifies multi-site management, common in web hosting.

CAVEATS

Requires root (use sudo). Fails if site file missing or already enabled (symlink exists). Reload Apache after use; changes not active until then. Not for non-Debian Apache installs.

DIRECTORIES

/etc/apache2/sites-available/: config files.
/etc/apache2/sites-enabled/: active symlinks.

EXAMPLE

sudo a2ensite 000-default
sudo systemctl reload apache2
a2ensite -l (list sites)

HISTORY

Introduced in Debian's Apache2 package (~2005, Apache 2.2 era) to streamline virtual host management via symlinks, replacing manual edits.

SEE ALSO

Copied to clipboard