Why Nginx has no sites-available directory

Find the include layout used by your Nginx installation and add site configuration without relying on a distribution-specific convention.

Best practices
Illustration of server operations and request logs

sites-available and sites-enabled are a packaging convention, not directories required by Nginx. Debian-family packages often use them; other packages, container images, and source installations may load site files from conf.d or another path.

Inspect the include layout first

sudo nginx -T

Use the binary and startup options for your instance. Find the include statements within http. The files they reference determine what is loaded, regardless of directory names.

A Debian-style layout commonly looks like:

/etc/nginx/
  nginx.conf
  sites-available/
  sites-enabled/

sites-available holds configuration files, while sites-enabled contains selected symlinks. If these directories are missing but you intend to use that convention, create them and ensure the main configuration includes the enabled directory:

sudo mkdir -p /etc/nginx/sites-available /etc/nginx/sites-enabled

Inside the existing http block:

include /etc/nginx/sites-enabled/*;

Creating the directories alone does not make Nginx read them.

Use conf.d when that is the installation's convention

Many RPM-based installations and the standard Nginx container configuration use:

include /etc/nginx/conf.d/*.conf;

A site file such as /etc/nginx/conf.d/mysite.conf is loaded automatically when it matches the include pattern. There is no separate symlink-based enable step. Inspect the actual image or package configuration because custom builds may differ.

For a source installation, any suitable include path works. You can use the existing layout without recreating Debian's directories.

Add an optional enabled-sites convention

If the team chooses the symlink approach, first write the site file in sites-available, then enable it:

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

To disable that site, remove only its enabled symlink, then validate and reload again:

sudo rm /etc/nginx/sites-enabled/mysite
sudo nginx -t && sudo systemctl reload nginx

Confirm it really is the symlink you intend to remove. Keep a consistent team convention and avoid including the same site through two paths.

FAQ

Can sites-enabled contain ordinary files?

Yes. Nginx reads the files matched by the include; it does not require symlinks. Symlinks make it convenient to disable a site while retaining its source file.

Can conf.d and sites-enabled coexist?

Yes, when both are included. Check for duplicate hostname/listener definitions and files loaded twice. Directory names do not provide separate namespaces.

Does an empty wildcard include need a placeholder file?

No. An unmatched wildcard include normally has no files to load. A missing explicitly named file or a broken symlink is different and can fail configuration testing. Read the exact diagnostic instead of adding an empty file as a general workaround.

Reference: Nginx include directive.

Get a tailored plan

Contact us

Join the community

Scan with WeChat
to join the community

Try Guance

Start online and pay only for what you use.

Get started

Choose a Guance plan

Code hosting