nginx部署vue

vue打包

​ 使用命令

1
npm run build

生成打包文件,生成文件包含一个static文件夹以及一个index.html文件,位于项目的/dist目录下。

上传文件

​ 此处我将文件上传至 /data/wwwroot/mobile_school_h5/campus_micro/dm200 路径下。

nginx配置

nginx.conf配置

​ 在nginx.conf配置文件中添加

1
include vhost/*.conf;

api.conf文件编写

​ 在当前目录下创建 vhost文件夹,并在 vhost文件夹下创建 api.conf 配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
server
{
listen 8081;
server_name 139.196.109.5;
index index.html index.htm index.php;
root /data/wwwroot/mobile_school_h5/campus_micro/dm200;
location / {
try_files $uri $uri/ @router;
index index.html;
}

location @router {
rewrite ^.*$ /index.html last;
}
}

​ 此处可配置多个端口号,server_name 可以设置为IP,root为文件的存放路径,一般都在html下新建要给文件夹,存放当前目录。location是为了防止404找不到。

启动nginx

重新加载nginx命令如下:

/etc/init.d/nginx reload

启动nginx命令:

/etc/init.d/nginx restart

查看nginx启动状态命令:

/etc/init.d/nginx status

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值