DEV Community

Cover image for Stop Confusing sites-available and sites-enabled (Nginx Guide)
Rijul Rajesh
Rijul Rajesh

Posted on

Stop Confusing sites-available and sites-enabled (Nginx Guide)

When I used to work on nginx-related things, I usually only had to modify some files under sites-available. I knew of the existence of sites-enabled, which I didn’t have to play with much until recently.

If you are new to nginx, you will see such folders around which you will need to familiarize yourself with.

This article will give you an idea of what these folders do and how it fits into the big picture.

What is sites-available?

Just think of sites-available as a folder that contains all possible configs, whether they are active or not.

So that means you would sometimes see files that aren’t even used in sites-available.

From the name itself, we can determine that the folder denotes the configs that are "available" to be used.

Now let's see what sites-enabled means.

What is sites-enabled?

From the name, we can understand it’s the config files that are "enabled."

So these are the configs that nginx actually loads.

The contents of this folder are symlinks (files that point to another file) to the files under sites-available.

Example:

/etc/nginx/sites-available/
    config1
    config2
    config3
Enter fullscreen mode Exit fullscreen mode
/etc/nginx/sites-enabled/
    config1 -> ../sites-available/config1
    config2 -> ../sites-available/config2
Enter fullscreen mode Exit fullscreen mode

From the above example, we can see that config1 and config2 are enabled. But config3 is not.

This is because config1 and config2 have symlinks inside sites-enabled pointing to them.

Creating a symlink

Creating a file that points to another file is pretty simple.

Suppose we need to make a symlink for config3, which doesn’t have one yet.

Just run the following:

ln -s /etc/nginx/sites-available/config3 /etc/nginx/sites-enabled/config3
Enter fullscreen mode Exit fullscreen mode

Your symlink is created!

Wrapping up

Hope your confusions are clear regarding sites-available and sites-enabled. I had the same confusions too in the beginning :)

If you are a developer who is actively trying to learn new stuff and trying to solve problems, let me suggest you a platform to make your life easier. It’s free, open-source, and built with developers in mind.

👉 Explore the tools: FreeDevTools
👉 Star the repo: freedevtools

Top comments (0)