Installing Nginx

Beginner
6 min read
Updated: Nov 2026
3 platforms
Package install

Definition

Installing Nginx puts the nginx program on your computer so it can listen for HTTP requests. Most beginners use a package manager — you do not need to compile from source.

After install, start the service and open http://localhost/ (or your server IP). You should see the default Nginx welcome page.

Config

Start with this shape. Adjust paths for your server.

Nginx
sudo apt update
sudo apt install -y nginx
sudo systemctl enable --now nginx

On Ubuntu and Debian, apt is the usual path. Reload a terminal if the nginx command is not found right away.

Key Directives

NamePlain meaning
apt / yum / dnfLinux package managers that install the nginx package.
brewHomebrew on macOS: brew install nginx.
systemctlStart, stop, and enable the nginx service on systemd Linux.
nginx -vPrint the installed Nginx version.

Examples

Example 1 — Install on Ubuntu / Debian

Update packages, install Nginx, enable it on boot, and start it now.

Nginx
sudo apt update
sudo apt install -y nginx
sudo systemctl enable --now nginx
nginx -v
curl -I http://127.0.0.1/

How It Works

  1. apt install places binaries and a default site config.
  2. enable --now starts Nginx and keeps it after reboot.
  3. curl -I should show an HTTP response from the welcome page.

Example 2 — Install on macOS with Homebrew

Homebrew installs Nginx under its own prefix. Start it with brew services.

Nginx
brew install nginx
brew services start nginx
nginx -v
curl -I http://127.0.0.1:8080/

How It Works

  1. brew install nginx downloads the formula.
  2. brew services start runs Nginx in the background.
  3. Port tip: Homebrew often uses port 8080 by default — check the formula notes.

Example 3 — Install on Windows

Use the official Windows build from nginx.org, unzip it, and run nginx.exe from that folder.

Nginx
cd C:\nginx
nginx.exe
# stop later:
nginx.exe -s quit

How It Works

  1. Unzip the official Windows zip into a folder such as C:\nginx.
  2. Run nginx.exe from that folder (or add it to PATH).
  3. Open http://127.0.0.1/ in a browser for the welcome page.

Frequently Asked Questions

No. Beginners should use apt, Homebrew, or the official Windows zip. Building from source is for custom modules.
Run nginx -v. Then curl http://127.0.0.1/ or open that URL in a browser.
On many Linux packages: /etc/nginx/nginx.conf. Homebrew and Windows use different paths under their install folders.
Another web server may own port 80. Stop it, or change Nginx listen to another port while you learn.
Yes. The nginx.org open-source web server is free to use. Commercial products are separate.

Next: Controlling Nginx

Keep going through the beginner Nginx path.

Controlling Nginx →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful