Why is Nginx configuration organized as sites-available and sites-enabled?

●1 ●12 ●97
calendar_today • schedule2 min read
— Originally published at dev.to

Hello, I'm Ganesh. I'm building git-lrc, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. Star Us to help devs discover the project. Do give it a try and share your feedback for improving the product.

In this article, We will exploring how to do nginx configuration directory structure. Why it is organized in this way?

How are ngix config files organized?

Majorly nginx config files are organized in the following way:

  1. Main config file: /etc/nginx/nginx.conf This deal with setting up global configuration for nginx.
  2. Sites available directory: /etc/nginx/sites-available This deal with setting up sites configuration for nginx. Where we can write multiple site configuration files.
  3. Sites enabled directory: /etc/nginx/sites-enabled This deal with enabling sites configuration for nginx. Where we can enable sites configuration.
  4. Logs directory: /var/log/nginx This deal with logs configuration for nginx. Where we can see logs of nginx.
  5. Cache directory: /var/cache/nginx This deal with cache configuration for nginx. Where we can see cache of nginx.

How to write site configuration file?

A site configuration file is a file that is used to configure a site for nginx.

Which you can further read in official documentation https://nginx.org/en/docs/.

These configuration should be written in this directory.

/etc/nginx/sites-available

Once you write the configuration file. This will not enable the site.

How to enable the site?

To enable the site, you need to create a symbolic link from the sites-available directory to the sites-enabled directory.

For example, if you have a site configuration file named example.com in the sites-available directory, you can enable it by running the following command:

we should always test the configuration file before enabling it.

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

This will create a symbolic link from the sites-available directory to the sites-enabled directory.

The core reason for using symbolic link is that it will allow us to enable and disable the site without removing the configuration file.

if we directly put the configuration file in sites-enabled directory, then we need to remove the configuration file to disable the site.

That means if I want to update small change.
If the configration was copy to sites-enabled directory, then on nginx server restart, the changes will not be reflected.

so, to make it easier we use symbolic link.

Now once the site is enabled, we need to restart the nginx server to apply the changes.

sudo systemctl restart nginx

Finaly we can access the site in browser.

How to disable the site?

To disable the site, you need to remove the symbolic link from the sites-enabled directory.

sudo rm /etc/nginx/sites-enabled/example.com

By this process it will not delete the configuration file. We can enable and disable the site without removing the configuration file.

Conclusion

By this we understood how to enable and disable the site in nginx.

How configuration file is organized in nginx.

git-lrc

Any feedback or contributors are welcome! It’s online, source-available, and ready for anyone to use.
⭐ Star it on GitHub: https://github.com/HexmosTech/git-lrc

🔥 Join developers growing publicly
Share your knowledge, build in public, and grow your developer presence with a global community.

More Posts

SE Ranking Review (2026): Pros, Cons, and Verdict

floxolab - Oct 22

Why Isn't My Website Ranking on Google? 9 Real Reasons

Built2Win - Jun 26

Local-First: The Browser as the Vault

Pocket Portfolio - Apr 20

Topic Clusters for Small Sites: Avoid Cannibalization

floxolab - Sep 29

Dozens of email accounts: learning AI coding tools as a student

rahuldk1105 - Oct 27
chevron_left
1.5k Points • 110 Badges
68Posts
6Comments
5Connections
Right now I'm focused on LiveReview, AI code review that gives teams control over AI-generated code without slowing them down.

Related Jobs

View all jobs →

Commenters (This Week)

1 comment
1 comment
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!