將Vue3佈署上Windows的Nginx

將Vue3佈署上Windows的Nginx

首先到nginx的下載網址:https://nginx.org/en/download.html

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

解壓縮到任一硬碟槽的資料夾nginx-1.28.0

 

 

 

 

 

 

 

 

 

不要直接雙擊nginx執行檔,改以cmd切換目錄如下:

 

 

 

 

 

 

 

在conf資料夾中確認編輯nginx.conf改Port改為你想要的,預設是80

    server {
        listen       8050;#我改為8050
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html/dist;#將Vue3產生的dist資料夾放在html/dist資料夾內
            index  index.html index.htm;
        }
    }

輸入如下啟動nginx:

start nginx

打開工作管理員確認是否執行

 

 

 

若修改nginx.conf完成後,需要輸入命令如下重新啟動:

.\nginx -s reload

打開瀏覽器http://localhost:8050即可看到Vue3網頁出現