Onjsdev

Share


NGINX sites-available vs sites-enabled


By onjsdev

Feb 11th, 2024

While working with NGINX, sites-available and sites-enabled are directories commonly used to manage virtual hosts or server blocks. Let's discover differences between them.

sites-available

The sites-available directory contains configuration files for individual virtual hosts or server blocks. Each file in this directory represents a separate configuration for a specific website or application.

sites-enabled

The sites-enabled directory contains symbolic links to the configuration files in the sites-available directory. These symbolic links are active configurations that NGINX will use.

How They Work

Here's a typical workflow:

  • Create a new configuration file in sites-available for each virtual host or server block.
  • Use the ln -s command to create a symbolic link from sites-available to sites-enabled for the configurations you want to enable.
  • Reload or restart NGINX to apply the changes.

For example, to enable a site configuration:

sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
sudo service nginx reload

This structure provides a modular and organized way to manage NGINX configurations. You can keep various configurations in the sites-available directory and activate them as needed by creating symbolic links in the sites-enabled directory.

Conclusion

In this article, we have discovered the differences between sites-available and sites-enabled in NGINX.

If you want to learn more about Linux, then you can check the following articles: