windows下安装Nginx服务器 并配置多站点

文章来源:阿木工作室

windows下安装Nginx服务器 并配置多站点 - 阿木工作室 - 博客园

1、下载Nginx

  链接:http://nginx.org/en/download.html 

  本次测试时下载的是http://nginx.org/download/nginx-1.20.1.zip

2、修改Hosts文件 C:\Windows\System32\drivers\etc,增加两个虚拟域名

  127.0.0.1 nginx.sitea.com
  127.0.0.1 nginx.siteb.com

3、修改conf/nginx.conf配置文件,未避免与80端口冲突,测试监听的是8000端口。红色为新增部分。

    server {
        listen       8000;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

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

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    server {
        listen       8000;
        server_name  nginx.sitea.com;

        location / {
            root   F:/nginx_site/site1;
            index  index.html index.htm;
        }
    }

    server {
        listen       8000;
        server_name  nginx.siteb.com;

        location / {
            root   F:/nginx_site/site2;
            index  index.html index.htm;
        }
    }


 

4、Nginx启动停止等命令

  启动:

  D:\nginx>start nginx.exe

  D:\nginx>nginx.exe

  停止:

  D:\nginx>nginx.exe -s quit

  D:\nginx>nginx.exe -s stop

  重新载入

  D:\nginx>nginx.exe -s reload

  重新打开日志文件

  D:\nginx>nginx.exe -s reopen

  查看Nginx版本

  D:\nginx>nginx -v

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值