Windows上安装部署多个Nginx

安装

先按教程安装

解压缩到两个文件夹下:
e.g. D:\Programs\nginxD:\Programs\nginx-test

配置

D:\Programs\nginx\conf下的nginx.conf文件

server {
    listen       8088;
    server_name  localhost;

    location / {
        root   html;
        index  index.html;
    }

    error_log  logs/error_8088.log;  # 独立错误日志
    access_log logs/access_8088.log; # 独立访问日志
}

D:\Programs\nginx-test\conf下的nginx.conf文件

server {
    listen       8089;
    server_name  localhost;

    location / {
        root   html;
        index  index.html;
    }

    error_log  logs/error_8089.log;  # 独立错误日志
    access_log logs/access_8089.log; # 独立访问日志
}

启动

cd D:\Programs\nginx
start nginx
cd D:\Programs\nginx-test
start nginx

启动脚本(可选)

新建一个 start_all_nginx.bat

@echo off
cd /d D:\Programs\nginx
start nginx
cd /d D:\Programs\nginx-test
start nginx

访问验证

http://localhost:8088 → 显示 nginx 欢迎页
http://localhost:8089 → 显示另一个 nginx-test 的欢迎页

posted @ 2025-07-31 15:19  Ritchie^._.^  阅读(306)  评论(0)    收藏  举报