[英]How to publish a Node.js Server online so that it is always accessible by an outside application
I have searched everywhere for a solution to this problem but for whatever reason I cannot find a clear answer as to how I can carry out this task. 我到处都在寻找解决此问题的方法,但是无论出于何种原因,我都无法找到有关如何执行此任务的明确答案。
I have built a very simple server with node.js that accesses two numbers from a website API and outputs them onto a localhost port on my computer as shown below: 我用node.js构建了一个非常简单的服务器,该服务器从网站API访问两个数字并将它们输出到我计算机的本地主机端口上,如下所示:
My question is how can I take my server and make it accessible to applications without having to go into the command line and run the server file? 我的问题是如何获取服务器并使其可被应用程序访问,而不必进入命令行并运行服务器文件? Is there a way I can host it online instead of locally so that I can distribute the application and anyone with the application can pull from this server?
有没有一种方法可以在线托管而不是本地托管,以便我可以分发该应用程序,并且拥有该应用程序的任何人都可以从此服务器中提取信息? What would be the best way to go about accomplishing this task?
完成这项任务的最佳方法是什么?
Question 1: how can I take my server and make it accessible to applications without having to go into the command line and run the server file? 问题1:如何获取服务器并使其可被应用程序访问,而不必进入命令行并运行服务器文件?
To start a node server you will always need to use the console. 要启动节点服务器,您将始终需要使用控制台。 If you are not used to,it's time to start :) .
如果您不习惯,那就该开始了:)。 You will be using it not only for node servers but for administrating (almost) every server in the world.
您将不仅将其用于节点服务器,而且还将用于(几乎)管理世界上的每台服务器。
Question 2: Is there a way I can host it online instead of locally ? 问题2:有什么方法可以在线托管而不是本地托管?
There are a lot of nodejs hosting platforms, you can choose between PaaS solutions or IaaS solutions ( AWS EC2 , Digital Ocean , etc.) . 有很多nodejs托管平台,您可以在PaaS解决方案或IaaS解决方案( AWS EC2 , Digital Ocean等)之间进行选择。 Probability the easiest way to start ar PaaS services, in this blogbost you will find a good list of PaaS hosting providers.
概率是启动PaaS服务的最简单方法,在此博客中,您会找到一个不错的PaaS托管提供商列表。 Some of them have free plans.
其中一些有免费计划。
Heroku is probably one of the easiest ways to get started with deploying the application: https://devcenter.heroku.com/articles/getting-started-with-nodejs#introduction Heroku可能是开始部署应用程序的最简单方法之一: https : //devcenter.heroku.com/articles/getting-started-with-nodejs#introduction
However, if you are not familiar with git
, Microsoft Azure Webapps is also another great option: https://tryappservice.azure.com/ 但是,如果您不熟悉
git
,Microsoft Azure Webapps也是另一个不错的选择: https : //tryappservice.azure.com/
They both offer free plans which should get you up and running fast! 他们俩都提供免费计划,可以帮助您快速启动和运行!
我已经实现了Amazon AWS,它们在有限的时间内提供免费选项,但是仍然很棒,因为您可以完全控制控制台,在云上安装计算机时要小心,在线上有许多指南可供您遵循步骤, 这一个例如有一步一步的信息,尽量遵循的步骤,你将能够运行你的应用程序,并从任何公共网络上访问它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.