Gahing's blog Gahing's blog
首页
知识体系
  • 前端基础
  • 应用框架
  • 工程能力
  • 应用基础
  • 专业领域
  • 业务场景
  • 前端晋升 (opens new window)
  • Git
  • 网络基础
  • 算法
  • 数据结构
  • 编程范式
  • 编解码
  • Linux
  • AIGC
  • 其他领域

    • 客户端
    • 服务端
    • 产品设计
软素质
  • 面试经验
  • 人生总结
  • 个人简历
  • 知识卡片
  • 灵感记录
  • 实用技巧
  • 知识科普
  • 友情链接
  • 美食推荐 (opens new window)
  • 收藏夹

    • 优质前端信息源 (opens new window)
关于
  • 分类
  • 标签
  • 归档
GitHub (opens new window)

Gahing / francecil

To be best
首页
知识体系
  • 前端基础
  • 应用框架
  • 工程能力
  • 应用基础
  • 专业领域
  • 业务场景
  • 前端晋升 (opens new window)
  • Git
  • 网络基础
  • 算法
  • 数据结构
  • 编程范式
  • 编解码
  • Linux
  • AIGC
  • 其他领域

    • 客户端
    • 服务端
    • 产品设计
软素质
  • 面试经验
  • 人生总结
  • 个人简历
  • 知识卡片
  • 灵感记录
  • 实用技巧
  • 知识科普
  • 友情链接
  • 美食推荐 (opens new window)
  • 收藏夹

    • 优质前端信息源 (opens new window)
关于
  • 分类
  • 标签
  • 归档
GitHub (opens new window)
  • 中间件

  • 云原生

  • 分布式

  • 存储技术

  • 数据库

  • 服务部署

    • 服务利用率
    • nginx

      • LearningNginx
      • nginx部署前端资源
        • 注意
        • 使用 systemctl 管理nginx
      • nginx配置HOST请求头及与webpack-dev-server proxy的区别
    • web灰度发布方案
    • 虚拟化

  • 编程语言

  • 计算技术

  • 服务端
  • 服务部署
  • nginx
gahing
2019-03-01
目录

nginx部署前端资源草稿

  1. 在 /usr/local 下新建 xxx 文件夹
cd /usr/local
mkdir thingsBoard
cd thingsBoard
1
2
3
  1. 将前端打包资源文件放至 /usr/local/xxx 目录下

  2. 安装 nginx 依赖

cd /usr/local
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
1
2
  1. /usr/local 目录下下载 nginx tar 包并且解压
wget http://nginx.org/download/nginx-1.13.7.tar.gz
tar -xvf nginx-1.13.7.tar.gz
1
2
  1. 安装 nginx
cd /usr/local/nginx-1.13.7
./configure
make
make install
1
2
3
4

后续 nginx-1.13.7 相关文件和目录可以选择删除了 6. 配置 nginx

vi /usr/local/nginx/conf/nginx.conf
1
  1. 修改 http -> server 节点下 localhost 为如下:
location / {
    root /usr/local/xxx/;
    index index.html index.html;
}
location /api/ {
    proxy_pass http://x.x.x.x:xx;
}
1
2
3
4
5
6
7

并且将该配置项下 server 的 port 修改为 3000(静态资源访问地址),之后保存。

  1. 启动 nginx
cd /usr/local/nginx/sbin/
./nginx -t
#或者
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
1
2
3
4
  1. 若修改配置后,重启 nginx
/usr/local/nginx/sbin/nginx -s reload
1

# 注意

3~5 步骤可以采用在线安装的方式,不用下载编译的方式:

yum install nginx
1

采用此法安装的nginx,默认的配置文件位置在 /etc/nginx/nginx.conf

通过 find . -name "nginx.conf" 找到

启动程序为 /usr/sbin/nginx

# 使用 systemctl (opens new window) 管理nginx

  • 开机自启动
systemctl enable nginx
1
  • 启动
systemctl start nginx
1
  • 关闭
systemctl stop nginx
1
  • 重启:关闭再启动
systemctl restart nginx
1
  • 重载配置:nginx.conf 更新后,使用该命令更新
systemctl reload nginx
1
编辑 (opens new window)
上次更新: 2025/06/11, 23:06:59
LearningNginx
nginx配置HOST请求头及与webpack-dev-server proxy的区别

← LearningNginx nginx配置HOST请求头及与webpack-dev-server proxy的区别→

最近更新
01
我的 2024 总结
12-31
02
浅谈代码质量与量化指标
08-27
03
快速理解 JS 装饰器
08-26
更多文章>
Theme by Vdoing | Copyright © 2016-2025 Gahing | 闽ICP备19024221号-1
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式