Home Nginx Installing Installing NginxDefinition 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.
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 Name Plain 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 1. Install on Ubuntu / Debian 2. Install on macOS with Homebrew 3. Install on Windows Example 1 — Install on Ubuntu / Debian Update packages, install Nginx, enable it on boot, and start it now.
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 apt install places binaries and a default site config.enable --now starts Nginx and keeps it after reboot.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.
brew install nginx
brew services start nginx
nginx -v
curl -I http://127.0.0.1:8080/ How It Works brew install nginx downloads the formula.brew services start runs Nginx in the background.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.
cd C:\nginx
nginx.exe
# stop later:
nginx.exe -s quit How It Works Unzip the official Windows zip into a folder such as C:\nginx.Run nginx.exe from that folder (or add it to PATH).Open http://127.0.0.1/ in a browser for the welcome page.Frequently Asked Questions Do I need to build Nginx from source? No. Beginners should use apt, Homebrew, or the official Windows zip. Building from source is for custom modules.
How do I check that Nginx is installed? Run nginx -v. Then curl http://127.0.0.1/ or open that URL in a browser.
Where is the config file after install? On many Linux packages: /etc/nginx/nginx.conf. Homebrew and Windows use different paths under their install folders.
What if port 80 is already in use? Another web server may own port 80. Stop it, or change Nginx listen to another port while you learn.
Is the open-source Nginx free? Yes. The nginx.org open-source web server is free to use. Commercial products are separate.
CODETOFUN NEWS
Stay Ahead in Tech Get the latest IT news, programming updates, and technology trends directly on your phone.
About the author Developer, cloud engineer, and technical writer
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
Helpful Share Copy link Suggestion