a2dissite

web serverlinux
The a2dissite command is one of the most frequently used commands in Linux/Unix-like operating systems. a2dissite The a2dissite command is used to disable Apache2 website configurations. It removes symbolic links from the /etc/apache2/sites-enabled directory that were previously created by a2ensite. After disabling sites, Apache needs to be restarted to apply the changes.

Quick Reference

Command Name:

a2dissite

Category:

web server

Platform:

linux

Basic Usage:

a2dissite [options] [arguments]

Common Use Cases

  • 1

    Apache site disablement

    Disable Apache sites to stop serving content

  • 2

    Web server configuration

    Configure the Apache web server

  • 3

    Scripting

    Use in shell scripts to automate site disablement

  • 4

    Web hosting

    Host multiple websites on a single server

Syntax

a2dissite [OPTION]... [SITE]...

Options

Option Description
-q, --quiet Quiet mode; suppress informational messages
-m, --maintmode Disable the site in maintenance mode (for a specific Apache instance)
-f, --force Force disabling the site, ignoring dependency issues
-p, --purge Purge all traces of the site from the config
-h, --help Display help information

Examples

How to Use These Examples

The examples below show common ways to use the a2dissite command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

Basic Examples:

Disable a site configuration
sudo a2dissite example.com.conf
Disable default site
sudo a2dissite 000-default.conf
Disable a site and restart Apache
sudo a2dissite mysite.conf && sudo systemctl restart apache2
Check if a site is already disabled
sudo a2dissite -q mysite.conf && echo "Site is disabled" || echo "Site is not disabled"

Advanced Examples:

Disable a site for a specific Apache instance
sudo a2dissite -m apache2-custom mysite.conf
Force disabling a site even if other sites depend on it
sudo a2dissite -f mysite.conf
List all enabled sites before disabling
ls /etc/apache2/sites-enabled/*.conf | cut -d. -f1 | sed 's/.*///'
Disable all sites except the default one (use with caution)
for site in $(ls /etc/apache2/sites-enabled/*.conf | grep -v "000-default" | cut -d. -f1 | sed 's/.*///' ); do sudo a2dissite $site.conf; done

Try It Yourself

Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

Understanding Syntax

Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

Notes

Common Use Cases:

  • Taking websites offline temporarily for maintenance
  • Removing deprecated or outdated websites from a server
  • Troubleshooting website configuration issues by selectively disabling sites
  • Migrating websites to different servers
  • Managing multiple domains on a single Apache server

Tips:

  • Always restart Apache after disabling sites: sudo systemctl restart apache2
  • Use a2ensite to re-enable sites when needed
  • Check for syntax errors after configuration changes: sudo apache2ctl configtest
  • Site configuration files typically end with .conf extension
  • The default site is usually named 000-default.conf
  • Keep a backup of site configurations before disabling them
  • Disabling a site doesn't remove its configuration file from sites-available, only the symbolic link from sites-enabled

Tips & Tricks

1

Use the -q option to run in quiet mode

2

Use the -a option to disable all sites

3

Use the -M option to specify a site to be disabled

4

Use the -m option to specify a site to be disabled

5

Use the -c option to specify a configuration file

Common Use Cases

Apache site disablement

Disable Apache sites to stop serving content

Web server configuration

Configure the Apache web server

Scripting

Use in shell scripts to automate site disablement

Web hosting

Host multiple websites on a single server

Load balancing

Balance traffic across multiple servers

Related Commands

These commands are frequently used alongside a2dissite or serve similar purposes:

Use Cases

1

Apache site disablement

Disable Apache sites to stop serving content

2

Web server configuration

Configure the Apache web server

3

Scripting

Use in shell scripts to automate site disablement

4

Web hosting

Host multiple websites on a single server

5

Load balancing

Balance traffic across multiple servers

Learn By Doing

The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the a2dissite command works in different scenarios.

$ a2dissite
View All Commands
a2dissite - Apache2 Command for Disabling Website Configurations