Nginx

Nginx 1.24.0

FreeBSD 13

# freebsd-update fetch install
# pkg install -y nginx
# sysrc nginx_enable=yes
# service nginx start

# ee /usr/local/etc/nginx/nginx.conf

Ubuntu 24.04 LTS

$ sudo apt update && sudo apt upgrade
$ sudo apt install nginx
$ sudo nginx -v

$ sudo vim /etc/nginx/sites-available/default
$ sudo ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/
$ sudo nginx -t

$ sudo systemctl enable/disable nginx
$ sudo systemctl start/stop/restart/status nginx

Ubuntu 22.04 LTS

$ sudo apt update
$ sudo apt install nginx
$ sudo systemctl enable --now nginx
$ sudo systemctl start/restart/reload/stop/enable/disable nginx
$ sudo vim /etc/nginx/sites-available/default
$ sudo ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/

Centos 7 & 8

$ sudo dnf install nginx
$ nginx -v
$ nginx -V
$ sudo vim /etc/nginx/nginx.conf
$ sudo vim /etc/nginx/conf.d/*.conf

$ nginx -t
$ sudo vim /var/log/nginx/access.log
$ sudo vim /var/log/nginx/error.log
$sudo firewall-cmd --permanent --add-service=http
$sudo firewall-cmd --reload
$ sudo systemctl start/stop/status/enable/disable nginx
$ nginx -s stop/quit/reopen/reload
$ nginx -c filename

Firewall

$ sudo ufw app list
$ sudo ufw allow 'Nginx Full'
$ sudo ufw reload
$ sudo ufw status

Notes

reload[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)

Then it means nginx or some other process is already using port 80. You can kill it using:

sudo fuser -k 80/tcp

And then try restarting nginx again:

service nginx start
Licensed under CC BY-NC-SA 4.0
comments powered by Disqus