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 pageManaging 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, alwaysInstalling 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 installThe 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 problemsFirewall
sudo ufw allow 'Nginx Full' # 80 and 443Key Points
- Always run
nginx -tbefore reloading configuration. - Use reload (not restart) so active connections are not dropped.
- Sites live in sites-available, enabled via symlinks into sites-enabled.