本文共 1270 字,大约阅读时间需要 4 分钟。
绿色版nginx,下载解压即可使用。
vue编译之后会生成dist文件夹,目录结构如下: |——index.html |——static |——|——css |——|——js |——|——img |——|——fonts是一个单页面的应用,资源都是静态的,可以使用nginx做静态资源服务器。
步骤:
server { listen 801; #监听端口,默认801,即nginx启动后访问端口 server_name 10.20.61.55; #监听地址,改为真实Ip,便于任何人访问 #charset koi8-r; #access_log logs/host.access.log main; # 项目访问 http://10.20.61.55:801进入/配置,显示dist下的index.html location / { #root html; root D:/nginx-1.13.12/html/dist; # 配置为vue项目放置目录,配合history路由模式 index index.html index.htm; try_files $uri $uri/ /index.html; #配合history路由模式,解决页面一刷新404问题 } # 反向代理,重定向后台请求,当输入http://10.20.61.55:801/ruoyi-admin/时,重定向到http://10.20.61.55:8080/ruoyi-admin/ location ^~ /ruoyi-admin/ { proxy_pass http://10.20.61.55:8080/; #后台部署的真实路径 }}
D:\nginx-1.13.12>nginx -tnginx: the configuration file D:\nginx-1.13.12/conf/nginx.conf syntax is oknginx: configuration file D:\nginx-1.13.12/conf/nginx.conf test is successfulD:\nginx-1.13.12>
D:\nginx-1.13.12>start nginx #启动D:\nginx-1.13.12>nginx -s stop #停止D:\nginx-1.13.12>nginx -s reload #重启
转载地址:http://wzqgn.baihongyu.com/