简体   繁体   English

如何部署本地可访问的 spring/angular web 应用程序 local.network

[英]How to deploy spring/angular web application locally accessible on local network

I am confused about deploying my webapp on a local server that has to be accessible by devices on local.network.我对将我的 webapp 部署在本地服务器上感到困惑,而本地服务器必须可由 local.network 上的设备访问。

I've created a DB, a spring boot backend and an angular frontend.我创建了一个数据库、一个 spring 启动后端和一个 angular 前端。 I built them and have my WAR and dist files ready to be deployed.我构建了它们并准备好我的 WAR 和 dist 文件以供部署。 Let's say I have XAMPP installed on my PC, how can I deploy my webapp and DB on it and how do I make it accessible from all devices on the local.network?假设我的 PC 上安装了 XAMPP,我如何在其上部署我的 Web 应用程序和数据库以及如何使其可从 local.network 上的所有设备访问?

Thanks for your help感谢您的帮助

You can also use nginx. It can be a little simpler for your case.您也可以使用 nginx。对于您的情况,它可以稍微简单一些。

Q: How can I deploy my webapp in xampp?问:如何在 xampp 中部署我的 webapp?
A: go to /dist in angular. if js & html source files were not there then navigate to the folder containing them (if you are using angular universal and there was a /server directory, you should be running it on node man!) A: go 到 angular 中的 /dist。如果 js 和 html 源文件不在那里,那么导航到包含它们的文件夹(如果你使用的是 angular universal 并且有一个 /server 目录,你应该在 node man 上运行它!)

Q: How can I deploy my DB on xampp?问:如何在 xampp 上部署我的数据库?
A: You don't need to:|答:您不需要:|

Q: How do I make it accessible to all devices from the same.network?问:如何让来自同一个网络的所有设备都可以访问它?
A: first find your own machine ip where back end is running, then assign the api_url in endpoints of your endpoints in api.service.ts in angular or where ever you are calling httpClient methods. A: 首先找到你自己的机器 ip 后端正在运行,然后在 api.service.ts 中的端点的端点中api.service.ts在 angular 或者你调用httpClient方法的地方。

And that's it.就是这样。


You see, every time a device which is connected to your hotspot (the hotspot of the machin which runs the backend or generally a.network which that back end serving on) sends a request to your ip on what ever port (I think xampp is on 80 by default so you dont need to set any port in the url,) your xampp is on.你看,每次连接到你的热点的设备(运行后端的机器的热点或者通常是后端服务的网络)在任何端口上向你的 ip 发送请求(我认为 xampp 是默认情况下在 80 上,因此您无需在 url 中设置任何端口,)您的 xampp 已打开。 it will get a copy of the angular build which connects to your back end server ip and thus does the interactions, if you interact with database in spring boot.如果您在 spring 启动时与数据库交互,它将获得 angular 构建的副本,该副本连接到您的后端服务器 ip 并因此进行交互。 then that part is done locally.然后该部分在本地完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM