vue-cli的线上部署

来源:互联网 发布:吉林大学网络本科 编辑:程序博客网 时间:2024/05/17 04:27

1.生成部署文件

npm run build

把dist目录中的文件复制到服务器


1. Apache

如果只使用Apache做HTTP服务器,可以设置Apache的url重定向,将所有的请求路由到index.html

打开~\Apache\conf\httpd.conf文件
去除httpd.conf文件中LoadModule rewrite_module modules/mod_rewrite.so前面的#号
在httpd.conf文件中添加重定向规则
RewriteEngine on 
# 当访问路由地址为 /live 开头的,则将路由重定向到 /index.html
RewriteRule \/live.*$ /index.html


2. nginx

使用nginx做反向代理服务器,配置文件参考:

server {
    listen 80;
    server_name localhost:80;
    index  index.html;
    root /wwwroot/;
    location / {
        try_files $uri $uri/ /index.html;
    }
}







原创粉丝点击