linux 部署 vue-admin-element 项目

部署 vue-admin-element

  • 在vue.config.js中更改 将 publicPath :'/' 更改为 publicPath :'./'

  • 使用打包命令 npm run build:prod

  • 将生成的 dist 文件夹 上传到 服务器 /home

  • 配置 nginx.conf

     server {
            listen       80;
            server_name  localhost;
    
            #charset koi8-r;
    
            #access_log  logs/host.access.log  main;
     
            location / {
                root   /home;
                index  index.html index.htm;
                autoindex on;
                autoindex_exact_size on;
                autoindex_localtime on;
            }
            
            location /fishapi {
                proxy_set_header Host                    $host;
                proxy_set_header x-forwarded-for         $remote_addr;
                proxy_set_header X-Real-IP               $remote_addr;
                proxy_pass                               http://127.0.0.1:8000;
             }
             
            add_header Access-Control-Allow-Origin "*";
            default_type 'text/html';
            charset utf-8;
            #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;
            }
     }
    
  • 浏览器可以直接访问 http://x.x.x.x/dist

posted @   巫小诗  阅读(740)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 因为Apifox不支持离线,我果断选择了Apipost!
· 通过 API 将Deepseek响应流式内容输出到前端
点击右上角即可分享
微信分享提示