版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sundehui01/article/details/85595663
- 打包
首先我们使用 npm run build
来生成项目的静态页面,会在项目的根路径的dist
目录下
我们将dist
下的 index.html
和static
静态文件发布到服务器的某一目录下
- nginx配置
nginx安装完成,修改conf/nginx.conf文件, server 节点下 listen 修改监听端口, 添加子配置文件 include vhost/*.conf;
vue.conf文件内容
server {
listen 7001;
server_name localhost;
root /usr/local/edu-cloud/edu-vue;
location / {
index index.html index.php;
}
# 媒体资源文件
# TODO: 用一个static.hostmanager.com 之类的域名放置
location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 30d;
}
# 前端代码
# TODO: 用一个fe.hostmanager.com之类的域名放置
location ~ .*.(js|css)$ {
expires 1h;
}
}
重启nginx ,nginx -s reload