Nginx is a popular web server and content management system. It’s free and open source, and can be used on a wide range of platforms. If you’re running Nginx on your own computer, you can find its configuration folder in the following location: ~/.config/nginx/sites-available/default If you’re using Nginx as part of a web server, you’ll likely want to create a similar folder in the same location. This will contain your Nginx configuration files, as well as any other files that may be necessary for your site to function correctly.
The Usual Locations
The default location for the nginx configuration folder is:
This location likely is the default for all normal installs. If you installed nginx from your distro’s package manager, it’s likely located here.
Within this directory you have a few files, regardless of where the main folder is located on your drive:
nginx. conf, which is nginx’s primary configuration file. sites-available/, a directory that usually contains different configuration files for each individual domain name your server hosts. For example, sites-available/example. com may contain a block with ServerName example. com, though you can use these files for anything. sites-enabled/, a directory that contains symlinks to the configuration files in sites-available. It essentially acts as a toggle, and enables you to turn sites on and off by symlinking different files.
If you don’t have the folder at /etc/nginx/, your installation may have created it elsewhere, which is likely if you’ve compiled it yourself. In this scenario, it’s probably installed to the /usr/local/ folder, in one of the following root directories:
/usr/local/nginx/, the most likely scenario if you’ve compiled from source /usr/local/nginx/conf/ /usr/local/etc/nginx/
If it’s not here, it’s probably operating in a containerized environment, or something has gone wrong during installation. If so, you need to locate it manually.
How to Find The Config Folder Manually
Nginx provides a command for testing configuration file syntax before restarting and applying changes. You should run it whenever you make changes to prevent downtime due to crashes, but you can also use it to find the location of the file nginx is using.
The command is simply:
While it tests your configuration file, it also echos out the full path to it as well, regardless of where it’s installed:
If this function doesn’t run, you don’t have nginx installed in the first place (or it’s not on your system PATH).
Document Root Locations
You can change the document root to anything you want, so it doesn’t matter as much as the config locations. The default location should be:
/var/www/html/ on Debian-based systems like Ubuntu /usr/share/nginx/html/ on RHEL-based systems like CentOS
Either way, the document root is hardcoded in the configuration files, so you can find it from there.