vue部署到nginx 超簡(jiǎn)單

0.安裝SecureCRT

https://www.vandyke.com/products/securecrt/

下載完成后 打開SecureCRT連接你的阿里云你的實(shí)例

1.安裝nginx

yum install nginx

systemctl start nginx // 啟動(dòng)nginx

輸入 公網(wǎng)ip 如果出現(xiàn) welcome nginx 則成功

2.安裝lrzsz

yum install nginx

3.編譯vue項(xiàng)目(build)

4.壓縮dist

tar -czf dist.tar.gz dist

5.SecureCRT里輸入

cd /home
mkdir vue
cd vue
rz
選擇 dist.tar.gz 上傳

6.到上傳好的目錄里解壓:

tar -xzvf dist.tar.gz

7.配置nginx

find / -name nginx
vim /etc/nginx/nginx.conf

nginx.conf

server {
    listen       80;
    server_name  localhost;
    root         /usr/share/nginx/html;
    
    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;
    
    location / {
            root /home/vue/dist;
            # 如果你配置router mode:history
            try_files $uri $uri/ /index.html;
            index index.html;
    }
    
    error_page 404 /404.html;
        location = /40x.html {
    }
    
    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
}
  1. 重啟nginx
nginx -s reload
  1. 輸入的公網(wǎng)ip到瀏覽器 成功
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容