Skip to main content
In this lesson you’ll install and verify Nginx on an Ubuntu system, inspect its configuration, and confirm the service responds locally. The same workflow applies to other Linux distributions — on CentOS/RHEL use yum or dnf instead of apt. Links to official docs are included for further reading.
If you’re on Debian/Ubuntu use apt (or apt-get for scripts). On CentOS/RHEL use yum or dnf. Package names and service management with systemctl are the same across most modern distributions.

Overview

Steps covered:
  1. Update package lists
  2. Install Nginx
  3. Start and verify the Nginx service
  4. Confirm Nginx responds locally
  5. Review Nginx configuration files
  6. Check Nginx logs
Recommended references:

1) Update package lists

Update the local package index so you install the latest package metadata. Note: apt update only refreshes metadata — it does not accept -y. Use -y with commands that change the system like apt install or apt upgrade.

2) Install Nginx

Install Nginx using apt install. The sample below runs interactively (no -y) so you can see the prompt; add -y to accept automatically in scripts.
It is normal for Nginx to pull in related modules and helper packages.

3) Start and verify the Nginx service

Check the service status with systemctl. If the service is inactive, start it and verify it becomes active.
Focus on the Active: active (running) line to confirm the service is up.
Before reloading Nginx after any configuration change, validate the config syntax to avoid downtime: sudo nginx -t. If the test passes, apply changes with sudo systemctl reload nginx.

4) Confirm Nginx is responding

Make a local HTTP request with curl to verify the default site:
A default installation returns the “Welcome to nginx!” HTML page, confirming the server is responding on localhost.

5) Review Nginx configuration files

On Debian/Ubuntu, Nginx configuration lives under /etc/nginx. A typical directory listing looks like this:
A simplified excerpt of a typical /etc/nginx/nginx.conf:
Notes on important elements:
  • The http block contains global HTTP settings, logging, gzip, etc.
  • access_log and error_log define where logs are written (default: /var/log/nginx/).
  • Include lines load additional files:
    • include /etc/nginx/conf.d/*.conf; loads .conf files from conf.d.
    • include /etc/nginx/sites-enabled/*; loads enabled site definitions.
  • Best practice: place site server { ... } blocks in sites-available/ and symlink enabled ones into sites-enabled/.
The example ssl_protocols line lists TLSv1 and TLSv1.1. For production, enable only modern protocols (for example: ssl_protocols TLSv1.2 TLSv1.3;) and follow current TLS hardening guides. Older protocols are insecure.
Common commands and file locations:

6) Check logs

Nginx logs live in /var/log/nginx. Immediately after install they may be minimal:
As you serve traffic or test sites, access.log and error.log will populate. You can configure per-site log paths within each server block.
That’s it for this lesson. To practice, create two sample virtual hosts under sites-available/, enable them by symlinking into sites-enabled/, and test access and logging.

Watch Video