Step-by-Step Guide to Installing and Configuring Nginx on Windows and Linux

This tutorial walks through the fundamentals of Nginx, explains its main features, details version choices, outlines the directory layout, and provides complete step‑by‑step commands for installing and configuring Nginx on both Windows and CentOS Linux environments.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Step-by-Step Guide to Installing and Configuring Nginx on Windows and Linux

Introduction

Nginx is a critical component in modern web architectures, widely used in LNMP stacks for its high availability, hot‑deployment, and reverse‑proxy capabilities.

Nginx Versions and Download Options

Three main edition choices are available:

Nginx Community Edition

Nginx Enterprise Edition (feature‑compatible with Community)

Taobao‑optimized builds (e.g., Tengine) that focus on I/O performance.

Version branches include:

MainLine – active development

Stable – production‑ready releases

Legacy – older releases for compatibility.

For the tutorial we use the Stable 1.16.1 release, which provides both source tarballs for Linux and pre‑built binaries for Windows.

Nginx Directory Structure

The extracted directory contains:

conf : configuration files (e.g., nginx.conf)

contrib : optional Vim syntax files

doc : documentation and licenses

html : default web root (contains index.html and 50x.html)

logs : log files

temp : temporary files

Windows Installation

1. Run the executable directly: .\nginxpath\nginx.exe If the process stays idle, the server started successfully.

2. Open a browser and navigate to http://localhost:80 to verify.

3. If the port is occupied, find the PID: netstat -ano | findstr 80 4. Terminate the conflicting process: taskkill /F /PID <pid> 5. Restart Nginx using the command from step 1.

Linux (CentOS) Installation

1. Install required dependencies:

yum install gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel -y

2. Extract, configure, and install Nginx:

tar -zxvf Nginx-1.16.1.tar.gz
cd Nginx-1.16.1
cd contrib
mv contrib ~/.vim
cd ..
./configure -prefix=/path/Nginx
make && make install

3. Start Nginx and test:

cd /path/Nginx
./nginx
curl http://localhost

4. Common management commands:

./nginx -s reload   # hot reload
./nginx -s stop    # stop server
./nginx -t         # test configuration syntax

Nginx.conf Configuration Example

Typical configuration steps:

# Edit the main configuration file
cd conf
vim nginx.conf

worker_processes  1;

events {
    worker_connections 1024;
}

http {
    include mime.types;
    default_type application/octet-stream;
    sendfile on;
    keepalive_timeout 60;

    server {
        listen 80;
        server_name localhost;
        charset koi8-r;
        root html;
        index index.html index.htm;
        location / {
            # serve static files
        }
        error_page 404 /404.html;
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
            root html;
        }
    }
}

Conclusion

Nginx’s reverse‑proxy, hot‑deployment, and scalability make it indispensable for modern micro‑service architectures. This guide covered both Windows and CentOS installation procedures, directory layout, essential commands, and a basic nginx.conf configuration to get a web server up and running.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

BackendLinuxWindows
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.