linux nginx配置node.js,nginx部署nodejs前端项目

前端项目打包

下载nodejs

下载地址:https://nodejs.org/en/download/

执行npm -v,查看安装是否成功。

下载nodejs依赖包

在项目目录下执行 npm i

Compiled successfully!

The app is running at:

http://localhost:8007/

项目打包

npm run build

打包后的代码保存在 /dist目录下

linux nginx部署前端项目

配置文件:nginx.conf

38895320440d88d0b56422e79993c761.png

部署项目的配置在 /conf.d/*.conf

server {

listen 9898; #监听的端口

server_name localhost; #域名

location / { #/表示匹配目录下所有文件

root /home/weblogic/hermes/caxs-mds-front; #打包代码所在目录

}

}

重启nginx

nginx -s reload

访问服务器域名:9898,即可访问到前端项目的index页面。

windows系统nginx部署前端项目配置文件:nginx.conf

server {

listen 8000;

server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html

#

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root html;

}

location / {

proxy_pass http://127.0.0.1:8007/;

proxy_redirect default ;

}

location /hermes-web/ {

proxy_pass http://10.10.7.66:8087/hermes-web/;

proxy_redirect default ;

}

}

重启nginx

nginx.exe -s stop

start nginx.exe

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值