linux nginx配置node.js,nginx部署nodejs前端项目 您所在的位置:网站首页 巧克力的小表情图片 linux nginx配置node.js,nginx部署nodejs前端项目

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

2023-11-05 11:55| 来源: 网络整理| 查看: 265

前端项目打包

下载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



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有