Amazon Cloud Code Deployment (NodeJS)

Source: Internet
Author: User

First you need to use SSH or putty to login to the AWS EC2 Linux instance (using Putty in Windows to connect to the Linux instance see: Connecting Amazon Cloud Servers in Windows).

I. Installation of two software to facilitate file transfer

1. WinSCP WinSCP is an open-source graphical SFTP client that uses SSH in a Windows environment. The SCP protocol is also supported. Its main function is to copy files securely between local and remote computers.

Support for SSH-1, SSH-2-based SFTP and SCP protocols [2] Support batch scripts and command line mode multiple semi-automatic, automated directory synchronization methods The built-in Text editor supports SSH password, keyboard interaction, public key and Kerberos (GSS) validation through with the pageant ( PuTTY Agent) Integrated support for various types of public key authentication provides Windows Explorer with the Norton Commander interface optionally stores session information that can be set in the configuration file instead of the registry, suitable for operation on mobile media 2.Xshell is a powerful secure terminal emulation software that supports SSH1, SSH2, and the Telnet protocol of the Microsoft Windows platform. Xshell Secure connections to remote hosts via the Internet and its innovative design and features help users enjoy their work in a complex network environment Two. Installing the NODEJS environment in a Linux instance
    • In the console, enter "wget https://nodejs.org/download/release/v5.3.0/node-v5.3.0.tar.gz" to download the source code to the server locally.
    • In the console, enter "Tar-zvxf node-v5.3.0.tar.gz" to extract the source code.
    • In the console, enter "CD node-v5.3.0/&&./configure && make" to go to the source code root, configure compilation options and start compiling Nodejs source code (you may need to install the compilation tools such as GCC, g++, Make,ubuntu You can use the command "sudo apt-get install build-essential" to install the C + + compiler environment.
    • In the console, enter "sudo make install" to install the compiled Nodejs program, enter "Node-v" to test whether the installation is successful, the current version will be displayed (in this case, v5.3.0)
three. Copy the source code to the server

In this example, Windows uses WINSCP to copy files and then describes the configuration of WINSCP. The configuration WINSCP process is as follows:

    • Download and install the WinSCP tool.
    • Open WinSCP and click New site.
    • Select "SCP" in the File Protocol option.
    • Fill in the hostname (which can be the public DNS or public IP for the instance), and the port uses the default of 22.
    • Fill in the User name Ubuntu (other Linux instances are ec2-user).
    • Open Advanced, select the server. PPK key file in the Ssh-> authentication and key file, click OK to complete the setup.
    • Finally click Login to connect to the server, supporting the copying of local files to the remote server.

Follow the above steps to perform the configuration process successfully, copy the local source code to the server, in this case the project directory named "Hello", including "Hello.js" and "Package.json" two files. The detailed contents are as follows:

Hello.js

var http = require (' http '); Load Nodejs HTTP Module//Create server object var server = Http.createserver (function (request, response) {    Response.writehead (200, {') Content-type ': ' Text/plain '}); Set the response header    Response.Write ("Hello, world!");//Set the appropriate content    Response.End ();//End request}); Server.listen (+);  Listens on the specified port and needs to be set in the EC2 Web Console to allow inbound from the specified TCP port.

  

Package.json

1234567891011 {  "name": "hello",   "version": "0.0.0",   "author": "[email protected]",  "private": true,  "scripts": {    "start": "node hello.js"  },  "dependencies": {  }}
Open Test Program
    • Go to the source directory under the server console to execute "NPM start" to start executing the program (if the code also relies on other NODEJS modules, you need to perform "NPM intsall" to install the dependent modules first).
    • Enter the public DNS or public IP plus port number of the instance in the browser to access the test program and get "Hello world!" Response.

The code is deployed to this end.

Reference:

Amazon Cloud Code Deployment (NodeJS)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.