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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM