I noticed my install of nginx has three folders called
etc/nginx/sites-available etc/nginx/sites-enabled etc/nginx/conf.d
Do I really need these if I just want to work directly in the etc/nginx/nginx.conf
file and remove the include
lines that include these items in nginx.conf
? Are these directories used for anything else that would mess things up if I delete them?
Important information. If you are still using sites-available/sites-enabled pattern, you should edit files only in the sites-available directory. Never edit files inside the sites-enabled directory. Otherwise you can have problems if your editor runs out of memory or, for any reason, it receives a SIGHUP or SIGTERM.
💡 Nginx on Linux makes use of symlinks in a smart way to enable site configurations. 👉🏼 "sites-available" folder holds all your site configurations. In the "sites-enabled" folder you create symlinks to the previous folder for the sites you wish to enable.
conf and for NGINX Plus is placed in the /etc/nginx directory. (For NGINX Open Source , the location depends on the package system used to install NGINX and the operating system. It is typically one of /usr/local/nginx/conf, /etc/nginx, or /usr/local/etc/nginx.)
/etc/nginx/sites-enabled/default is the path given to the default website for Debian based systems. They are usually links to files contained /etc/nginx/sites-available . /etc/nginx/conf. d is a path used in most configurations including Debian derivatives like Ubuntu and other distro's like CentOS etc.
No, they are not needed if you define your server blocks properly in nginx.conf, but it's highly suggested. As you noticed, they are only used because of the include /etc/nginx/sites-enabled/*;
in nginx.conf.
For curiosity, is there a reason why you do not want to use them? They are very useful; easier to add new sites, disabling sites, etc. Rather than having one large config file. This is a kind of a best practice of nginx folder layout.
Important information:
You should edit files only in sites-available
directory.
Never edit files inside the sites-enabled
directory, otherwise you can have problems if your editor runs out of memory or, for any reason, it receives a SIGHUP or SIGTERM.
For example: if you are using nano
to edit the file sites-enabled/default
and it runs out of memory or, for any reason, it receives a SIGHUP or SIGTERM, then nano
will create an emergency file called default.save
, inside the sites-enabled
directory. So, there will be an extra file inside the sites-enabled
directory. That will prevent Apache or NGINX to start. If your site was working, it will not be anymore. You will have a hard time until you find out, in the logs, something related to the default.save
file and, then, remove it.
In the example above, if you were editing the file inside the sites-available
directory, nothing bad would have happened. The file sites-available/default.save
would have been created, but it wouldn't do any harm inside the sites-available
directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With