This tutorial will guide you on how to get Nginx server installed and configured on an Ubuntu Linux 18.04 LTS server.
Nginx is one of the most popular web servers in the world and is responsible for hosting some of the largest and highest-traffic sites on the internet. It is more resource-friendly than Apache in most cases and can be used as a web server or reverse proxy.
Nginx Configuration Files Structure
- All configuration files are located in the /etc/nginx/ directory.
- Nginx main configuration file is at /etc/nginx/nginx.conf.
- It's best practice to create a separate configuration file of each domain for better maintainability.
- New server blocks (configuration file) of each domain should be stored in /etc/nginx/sites-availabledirectory. You need to make symlink of these configuration files at /etc/nginx/sites-enabled to take in used by Nginx.
- Activating server blocks is done by creating a symlink (a pointer) from the configuration file sites in a /etc/nginx/sites-enabled directory to the sites-enabled directory.
- The default server web root directory is /var/www/html
- It's best practice to to follow standard naming convention. Nginx server block files name should as domain name and must end with .conf extension. For example, your domain name is example.com then server block file name should example.com.conf
- Nginx log files (access.log and error.log) are located in the /var/log/nginx/ directory. It's also recommended to have a different access and error log files for each server block.