简体   繁体   English

如何在线正确上传本地主机网站?

[英]How do I properly upload a localhost website online?

I have a ReactJS project for my Front and a NodeJS project/server using Express for my back.我有一个ReactJS项目我的接待和使用的NodeJS Express的我的背投影/服务器。 My Front depends on my Back because for example in the Login part, I ask the server if the user is already in our database.我的前台取决于我的后台,因为例如在登录部分,我询问服务器用户是否已经在我们的数据库中。

To execute my project, I just open 2 terminals and do npm start in each Front and Back.为了执行我的项目,我只打开 2 个终端并在每个 Front 和 Back 中执行npm start

I know that in order to upload a website with a personal domain name, I should:我知道为了上传带有个人域名的网站,我应该:

  1. Buy a domain name购买域名
  2. Pay a subscription to a web-hosting website like GoDaddy , Bluehost , Hostgator etc.订阅网络托管网站,如GoDaddyBluehostHostgator等。

If I pay a subscription to some web-hosting website, will I be able to put my Front AND Back?如果我订阅了一些网络托管网站,我能把我的前和后放吗? I have seen some tutorials online and people just make a simple HTML/CSS/JS website and upload it.我在网上看过一些教程,人们只是制作了一个简单的 HTML/CSS/JS 网站并上传。 I never see anyone uploading their own Server and making requests to it.我从未见过有人上传自己的服务器并向其发出请求。

I'm not asking to merge both my Front and Back.我不是要合并我的 Front 和 Back。 I want to know how do people upload online their React front and Node Server online, for them to be always executed and talking to each other.我想知道人们如何在线上传他们的 React 前端和 Node Server,以便它们始终被执行并相互交谈。 I just can't see the relationship and explanation on how uploading both.我只是看不到如何上传两者的关系和解释。

Your react frontend doesn't really need a server, you'd need to build a release bundle and that can be served from any static filehoster.您的 React 前端并不真正需要服务器,您需要构建一个发布包,并且可以从任何静态文件主机提供服务。 For your backend though you need a node.js hoster like AWS or heroku, follow their tutorials to upload your project.对于您的后端,尽管您需要像 AWS 或 heroku 这样的 node.js 托管程序,但请按照他们的教程上传您的项目。

You could also then serve both from the same hoster and read into connecting frontend and backend like mentioned by @FedeSc然后,您还可以从同一主机提供服务,并阅读@FedeSc 提到的连接前端和后端

An easy solution for your use case could be digitalocean or any similar site that offers a whole virtual system to operate with.对于您的用例,一个简单的解决方案可能是digitalocean或任何提供完整虚拟系统以供操作的类似站点。 You can then ssh into the server as it was your computer and use the terminal there.然后,您可以 ssh 进入服务器,因为它是您的计算机并在那里使用终端。 It is cheaper than Heroku if you wish to make your site available without 30 seconds waiting time (that is what Heroku does in a serverless fashion if you are on a free plan).如果您希望在没有 30 秒等待时间的情况下使您的站点可用(如果您使用免费计划,这就是 Heroku 以无服务器方式所做的事情),它比 Heroku 便宜。 There are dozens of sites like this but I had good experience with digitalocean and a basic plan is $5/mo.有很多这样的网站,但我在 digitalocean 方面有很好的经验,基本计划是 5 美元/月。

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

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