适用于初学者的AWS上的Node.js应用 [英] Node.js app on AWS for beginner

查看:126
本文介绍了适用于初学者的AWS上的Node.js应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几周前,我开始学习node.js,刚刚完成了我的第一个小项目,这是一个使用socket.io和express的基本实时聊天网站.我项目的结构如下:

I started learning node.js a couple weeks ago and just finished my first small project, a basic live chat website using socket.io and express. The structure for my project looks like this:

ChatApp
   |
   |____backend.js                      // node server side code
   |
   |____ static
   |        |
   |        |_____ libs
   |                 |
   |                 |___ app.js        // front end logic
   |                 |
   |                 |___ jquery.min.js                       
   |____ views
            |
            |_____ index.html           // Client website

我现在的目标是学习如何使用AWS使我的应用程序可用,以便位于不同计算机上的人们可以互相交谈,而不仅仅是我在本地服务器上.我尝试遵循本指南,该指南使用Elastic Beanstalk进行了部署一个示例存储库,但是我很难看如何将其转换为我的文件夹结构,因为它们甚至都没有HTML.

My goal right now is to learn how to use AWS to make my application available so people on different machines can talk to one another, not just me on my local server. I tried following this guide which uses Elastic Beanstalk to deploy a sample repository, but I'm having a hard time seeing how to translate it to my folder structure, since they don't even have an HTML for instance.

我的服务器代码如下:

//*****************//
// Sets up backend //
//*****************//
var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);
var express = require('express');
server.listen(8080);
app.use(express.static(__dirname + '/views'));
app.use(express.static(__dirname + '/static'));
var users = [];

//*****************//
// Sends out html  //
//*****************//
app.get('/', function(req, res){ // Main page
    res.render('index.html');
});

//*************************//
// Handles socket requests //
//*************************//
io.on("connection", handleIO); // Called when user connects

function handleIO(socket){
    console.log('Client connected...');
    // Bunch of socket.io code I didn't think was necessary to add
}

无论如何,我想知道是否有任何开明的人能帮助菜鸟部署他的第一个网站.如果您可以给我一个总体概述,或者给我指出一个概述,那么我将不胜感激,因为AWS刚开始时可能会令人生畏.谢谢.

Anyways, I was wondering if any of you enlightened folks could help a noob out with deploying his first website. If you could either give me a general outline or point me to one I'd really appreciate it as AWS can be pretty intimidating when first starting out. Thanks.

推荐答案

我会说直接进入Amazon Web Services是一个错误,因为AWS只是您可以作为云管理员执行的数百万个任务的抽象层.

I would say jumping straight into Amazon Web Services would be a mistake as AWS is just an abstraction layer on millions of tasks that you can perform as a Cloud Administrator.

如果您没有服务器管理的基本概念或没有以类似的方式工作,则可能会适得其反.

If you do not have the basic concepts of server administration or have not worked in a similar capacity, it can prove to be counter-productive.

如果您仍然愿意跳下去,请按照以下步骤操作:

Still if you are willing to make the jump, here are the steps I would recommend:

  1. 了解如何创建EC2实例
  2. 在您的EC2实例上设置/安装所需的软件
  3. 将您的代码传输到EC2实例
  4. 配置/运行您的应用程序.

如果有帮助,EC2只是具有外壳程序访问权限的VPC,您可以像通常在台式机Linux上一样通过命令行使用它.

If it helps, EC2 is just a VPC with shell access and you can use it through the command line as you normally would a desktop linux.

这篇关于适用于初学者的AWS上的Node.js应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆