Understanding Service Config Files in Nginx and Apache on Ubuntu: Demystifying the ‘sites-enabled’ Directory

When it comes to web server software, two of the most popular choices are Nginx and Apache. These web servers power a large portion of the internet and are commonly deployed on Ubuntu servers. While the software itself is well-documented, one area that often puzzles newcomers is the configuration file structure—specifically, the use of directories like sites-enabled. In this article, we’ll explore the layout of service configuration files in Nginx and Apache on Ubuntu, demystify the role of the sites-enabled directory, and explain how it all works together.

Configuration File Layout


For Apache on Ubuntu, the main configuration file is usually located at /etc/apache2/apache2.conf. However, this is not the only configuration file; Apache employs a modular approach for better manageability. You’ll find various other configurations in sub-directories like mods-enabled, conf-enabled, and sites-enabled.


In the case of Nginx, the primary configuration file is found at /etc/nginx/nginx.conf. Like Apache, Nginx also uses a modular system, and you’ll find additional configurations in directories such as sites-available, sites-enabled, and conf.d.

The Role of ‘sites-enabled’

So, what’s special about the sites-enabled directory? Why is it there, and how does it work?

The sites-enabled directory contains symbolic links to configuration files that are actually stored in another directory, commonly named sites-available. The idea is to separate the available configurations (sites-available) from the ones that are currently active (sites-enabled).

Why Use This Approach?

  1. Ease of Management: By segregating enabled and available sites, you can quickly activate or deactivate configurations without actually deleting files.
  2. Atomic Changes: This approach allows for making changes in an atomic manner. You can prepare a new configuration in sites-available and only symlink it to sites-enabled when you’re ready to go live.
  3. Safety: Keeping the actual files in sites-available means that accidental deletions in sites-enabled won’t cause loss of configurations.
  4. Flexibility: This structure also makes it easier to manage configurations via automation tools and scripts.

How It Works: Symlinking and Activation

When you’re ready to activate a site configuration, all you need to do is create a symbolic link to the relevant file within sites-available.

For example, to enable a site in Apache:

sudo ln -s /etc/apache2/sites-available/mysite.conf /etc/apache2/sites-enabled/ sudo systemctl reload apache2

In Nginx:

sudo ln -s /etc/nginx/sites-available/mysite /etc/nginx/sites-enabled/ sudo systemctl reload nginx

That’s it! Your web server will now read the symlinked file as if it were actually in the sites-enabled directory, making the specified site live.

Summing Up

The sites-enabled directory in Apache and Nginx on Ubuntu serves as a convenient way to manage your active web server configurations. By understanding how this system works, you can make your web server management tasks easier, safer, and more efficient.

Whether you’re setting up a single website or managing multiple web services, understanding the role and utility of the sites-enabled directory can make your life much easier. It’s a simple but effective system that highlights the beauty of modular configuration.

Scroll to Top