Installing Nginx

Harry · 12 Sep 2026 · 13 views

Install on Ubuntu / Debian

sudo apt update
sudo apt install -y nginx
sudo systemctl enable --now nginx
curl -I http://localhost   # expect 200 from the default page

Managing the Service

sudo systemctl status nginx
sudo systemctl reload nginx   # apply config without dropping connections
sudo systemctl restart nginx  # full restart
sudo nginx -t                 # test config syntax first, always

Installing the Latest (nginx.org)

# add the official repo, then:
sudo apt install -y nginx
# or build from source when you need custom modules
./configure --with-http_ssl_module --with-http_v2_module
make -j2 && sudo make install

The Default Layout

/etc/nginx/nginx.conf          # master config
/etc/nginx/sites-available/    # available virtual hosts
/etc/nginx/sites-enabled/      # symlinks to the enabled sites
/var/www/                      # default web roots
/var/log/nginx/access.log      # every request
/var/log/nginx/error.log       # errors and configuration problems

Firewall

sudo ufw allow 'Nginx Full'    # 80 and 443

Key Points

  • Always run nginx -t before reloading configuration.
  • Use reload (not restart) so active connections are not dropped.
  • Sites live in sites-available, enabled via symlinks into sites-enabled.
Share this post:

Comments (0)

Please login or register to comment.