如何发布我的第一个Node.js应用程序?

时间:2022-05-24 15:22:55

I've built a website which I'm serving through a basic Node.js server that I've built as well.

我已经建立了一个网站,我通过我已经构建的基本Node.js服务器提供服务。

I've created a mysitename folder which itself contains a public folder (containing all the .html, .css etc. files) as well as a server.js file (my server). I call node server.js from inside mysitename folder and everything is working fine on localhost:8080

我创建了一个mysitename文件夹,它本身包含一个公共文件夹(包含所有.html,.css等文件)以及一个server.js文件(我的服务器)。我从mysitename文件夹中调用了node server.js,并且在localhost:8080上一切正常

Now I want to publish it (in a dev environment, i.e. the URL would look something like this : http://mysitename.someservice.com) so that I can test it live.

现在我想发布它(在开发环境中,即URL看起来像这样:http://mysitename.someservice.com),以便我可以实时测试它。

I tried heroku.com but they couldn't have made the process of setting up my app to serve through them more confusing. It's so confusing it's ridiculous.

我尝试过heroku.com,但他们无法设置我的应用程序以通过它们服务更令人困惑。这太令人困惑了,这太荒谬了。

I thought that it was just a matter of uploading this mysitename folder online and then using some service to execute server.js

我认为这只是在线上传这个mysitename文件夹然后使用一些服务来执行server.js的问题

Is there a simpler, more "out-of-the-box" free service I could use and definitely less of the maze heroku appears to be, or is there a better step-by-step guide, at least, on how to do that using Heroku ?

是否有一个更简单,更“开箱即用”的免费服务,我可以使用,绝对不是heroku似乎是迷宫,或者是否有一个更好的分步指南,至少,如何做使用Heroku?

I followed the steps on the Heroku site, created a BitBucket Account and a repo with the folder I mentioned above and then I installed Source Tree but by the time I got to the last step nothing was working. I know I'm mentioning Heroku but I'd rather stay away from that riddle if there's a cleaner way of doing things.

我按照Heroku网站上的步骤,创建了一个BitBucket帐户和一个包含我上面提到的文件夹的回购,然后我安装了Source Tree,但是当我到达最后一步时没有任何工作。我知道我提到了Heroku,但如果有一种更清洁的做事方式,我宁愿远离那个谜语。

This is the first time I try to publish a site (let alone a site being served through my own server) so I would really appreciate the help as I'm completely in the dark right now.

这是我第一次尝试发布一个网站(更不用说通过我自己的服务器提供网站了)所以我真的很感激帮助,因为我现在完全处于黑暗中。

If this is not the forum for such a question please let me know and I'll remove it and then search elsewhere.

如果这不是这个问题的论坛,请告诉我,我将删除它,然后在其他地方搜索。

Thank you once again for your help!

再次感谢您的帮助!

1 个解决方案

#1


2  

I would suggest that you roll your own server, you'll have a lot more control and flexibility to experiment/make mistakes.

我建议你推出自己的服务器,你将有更多的控制和灵活性来试验/犯错误。

As you seem to be a beginner, you'll be able to learn at your own pace without being limited by the platform you're using. For example, Heroku's read-only filesystem, PostgreSQL database, etc...

由于您似乎是初学者,您将能够按照自己的进度学习,而不受您正在使用的平台的限制。例如,Heroku的只读文件系统,PostgreSQL数据库等......

What I'd suggest is to use Amazon EC2. The reason is simple, they give you a free instance for a year, it's like having a free PC in the cloud for you to play with. (No I'm not affiliated to amazon, just remembering the joy I experienced when I was just started and found that out).

我建议使用Amazon EC2。原因很简单,它们为您提供一年的免费实例,就像在云端有一台免费的PC供您玩。 (不,我不是亚马逊的附属,只记得我刚刚开始时所经历的快乐,并发现了这一点)。

You'll find a great tutorial here to deploy your first instance, it'll save you a few hours of research time.

你会在这里找到一个很棒的教程来部署你的第一个实例,它可以节省你几个小时的研究时间。

Tutorial

Once your server is setup, grab a cheap domain name from godaddy or namecheap, and point it to your server's IP. Your site will be up and running in no time, for about 3$ total.

设置好服务器后,从godaddy或namecheap中获取一个便宜的域名,并将其指向服务器的IP。您的网站将立即启动并运行,总计约3美元。

The whole process is very easy to do, and will give you far more knowledge than using one or the other online solutions. As a bonus, you will be able to run all sorts of things on your instance, while keeping your website alive.

整个过程非常简单,并且比使用一个或另一个在线解决方案提供更多的知识。作为奖励,您将能够在您的实例上运行各种各样的事情,同时保持您的网站活着。

And for all your problems, there is Stack Overflow.

对于你所有的问题,有Stack Overflow。

Happy Coding!

#1


2  

I would suggest that you roll your own server, you'll have a lot more control and flexibility to experiment/make mistakes.

我建议你推出自己的服务器,你将有更多的控制和灵活性来试验/犯错误。

As you seem to be a beginner, you'll be able to learn at your own pace without being limited by the platform you're using. For example, Heroku's read-only filesystem, PostgreSQL database, etc...

由于您似乎是初学者,您将能够按照自己的进度学习,而不受您正在使用的平台的限制。例如,Heroku的只读文件系统,PostgreSQL数据库等......

What I'd suggest is to use Amazon EC2. The reason is simple, they give you a free instance for a year, it's like having a free PC in the cloud for you to play with. (No I'm not affiliated to amazon, just remembering the joy I experienced when I was just started and found that out).

我建议使用Amazon EC2。原因很简单,它们为您提供一年的免费实例,就像在云端有一台免费的PC供您玩。 (不,我不是亚马逊的附属,只记得我刚刚开始时所经历的快乐,并发现了这一点)。

You'll find a great tutorial here to deploy your first instance, it'll save you a few hours of research time.

你会在这里找到一个很棒的教程来部署你的第一个实例,它可以节省你几个小时的研究时间。

Tutorial

Once your server is setup, grab a cheap domain name from godaddy or namecheap, and point it to your server's IP. Your site will be up and running in no time, for about 3$ total.

设置好服务器后,从godaddy或namecheap中获取一个便宜的域名,并将其指向服务器的IP。您的网站将立即启动并运行,总计约3美元。

The whole process is very easy to do, and will give you far more knowledge than using one or the other online solutions. As a bonus, you will be able to run all sorts of things on your instance, while keeping your website alive.

整个过程非常简单,并且比使用一个或另一个在线解决方案提供更多的知识。作为奖励,您将能够在您的实例上运行各种各样的事情,同时保持您的网站活着。

And for all your problems, there is Stack Overflow.

对于你所有的问题,有Stack Overflow。

Happy Coding!