当前位置: 首页 > news >正文

Mac Nginx 前端打包部署

安装homebrew

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

安装Nginx

brew install nginx

 nginx相关命令

nginx启动命令:nginx

nginx -s reload  #重新加载配置
nginx -s reopen  #重启
nginx -s stop    #停止
nginx -s quit    #退出
nginx -V         #查看版本,以及配置文件地址
nginx -v         #查看版本
nginx -c filename #指定配置文件
nginx -h #帮助

启动之后,在浏览器输入http://localhost:8080  或 http://127.0.0.1:8080/地址来打开nginx

前端打包

npm run build

之后会在dist文件夹中生成代码

前端部署

前往/usr/local/etc找到nginx.conf修改配置

http {

include mime.types;

default_type application/octet-stream;


sendfile on;

keepalive_timeout 65;

#root xxx/xxx配置项目路径,不配置的话默认是html文件夹

server {

listen 28866; //项目访问端口号

server_name localhost; //项目访问地址

location / {

try_files $uri $uri/ @router;#需要指向下面的@router 否则会出现vue 的路由在nginx 中刷新出现404

index index.html index.htm;

}

location @router {

rewrite ^.*$ /index.html last;

}

location /api/ { //【/api/ 】是nginx转发标识

proxy_buffer_size 64k;

proxy_buffers 32 32k;

proxy_busy_buffers_size 128k;

proxy_pass http://localhost:8880/api/tp/; //api服务器地址

proxy_redirect default;

}

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root html;

}

}

进入/usr/local/Cellar/nginx/1.27.2/html,将打包的前端复制到 目录下

打开终端,使用nginx命令启动

打开浏览器访问 http://localhost:28866

完~

 

http://www.lryc.cn/news/483533.html

相关文章:

  • 乳腺癌诊断分析——基于聚类分析实现
  • Ubuntu 22.04 安装配置opencv
  • 【软考】系统架构设计师-计算机系统基础(3):嵌入式系统
  • 实测运行容器化Tomcat服务器
  • 致敬苹果的国产手机,只会失去更多市场,iPhone一骑绝尘!
  • 《MYSQL45讲》kill不掉的线程
  • 单体架构 IM 系统之 Server 节点状态化分析
  • java xml 文本解析
  • Docker占用空间太大磁盘空间不足清理妙招
  • 编程之路,从0开始:字符函数和字符串函数
  • 化工防爆巡检机器人:在挑战中成长,为化工安全保驾护航
  • 音频采样数据格式
  • 【pytorch】常用强化学习算法实现(持续更新)
  • DAY59||并查集理论基础 |寻找存在的路径
  • Mybatis执行自定义SQL并使用PageHelper进行分页
  • OpenCV DNN
  • 什么时候需要复写hashcode()和compartTo方法
  • PostgreSQL 日志文件备份
  • 2023年MathorCup数学建模B题城市轨道交通列车时刻表优化问题解题全过程文档加程序
  • 数字农业产业链整体建设方案
  • awk那些事儿:在awk中使用shell变量的两种方式
  • 大数据面试题--kafka夺命连环问(后10问)
  • 智能量化交易的多样化策略与风险控制:中阳模型的应用与发展
  • 小皮PHP连接数据库提示could not find driver
  • 2024.11.13(一维数组相关)
  • 豆包MarsCode算法题:数组元素之和最小化
  • Hbase Shell
  • 激活函数解析:神经网络背后的“驱动力”
  • 【开源免费】基于SpringBoot+Vue.JS水果购物网站(JAVA毕业设计)
  • 推荐一款多物理场模拟仿真软件:STAR-CCM+