Nginx is an open-source web server, reverse proxy, load balancing software very used by the community.
Official website: https://www.nginx.com/
Facts about Nginx:
- nginx package from Debian 10 is not the latest version
- by default is running on port 80; it crashes at startup if the port is used
- if you want a module that is not built by default you need to rebuild the package; same for removing modules
- .htaccess is not an option provided by Nginx
Installation
- Update apt index package and install nginx package
sudo apt -y update
sudo apt -y install nginx
- Wait for command to finish and check nginx service
catalin@devops:~$ sudo systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2020-04-25 15:21:26 UTC; 16s ago
Docs: man:nginx(8)
Main PID: 6527 (nginx)
Tasks: 3 (limit: 9510)
Memory: 5.1M
CGroup: /system.slice/nginx.service
├─6527 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
├─6528 nginx: worker process
└─6529 nginx: worker process
Apr 25 15:21:26 devops systemd[1]: Starting A high performance web server and a reverse proxy server...
Apr 25 15:21:26 devops systemd[1]: Started A high performance web server and a reverse proxy server.
At this point nginx daemon is running on our machine and we can check in browser using machine ip and port 80.
Nginx directory structure
This information is also available on debian documentation.
Path | Purpose | Ref. |
./conf.d/*.conf | Extra configuration files. | #conf.d, #appincludes |
./fastcgi.conf | Commonly configured directives (nginx packaging team) | #params |
./fastcgi_params | Commonly configured directives (upstream version) | #params |
./koi-utf | Nginx Character Set | #charset |
./koi-win | Nginx Character Set | #charset |
./mime.types | Maps file name extensions to MIME types of responses | #mimetypes |
./nginx.conf | The primary configuration file. | #nginx.conf |
./proxy_params | Commonly configured directives | #params |
./scgi_params | Commonly configured directives | #params |
./sites-available/* | Extra virtual host configuration files | – |
./sites-enabled/* | Symlink to sites-available/<file> to enable vhost | – |
./snippets/*.conf | Configuration snippets that can be included in configs | – |
./apps.d/*.conf | Files included by /etc/nginx/sites-available/default | #appincludes |
./uwsgi_params | Commonly configured directives | #params |
./win-utf | Nginx Character Set | #charset |
Every installation comes with a default vhost activated, named default and can be checked in /etc/nginx/sites-available
.
Recommended is to create your vhost file inside sites-available and create after a symbolic link in sites-enabled.