GithubHelp home page GithubHelp logo

aws-ec2's Introduction

AWS EC2 Server Setup Instructions

This guide provides step-by-step instructions on how to set up a server on AWS EC2.

Prerequisites

Ensure you have an AWS EC2 instance ready for setup.

Steps

1. Install Git

Update your package manager and install Git:

sudo yum update
sudo yum install git

Verify the installation:

git version

2. Install Node.js Using NVM

Download and install NVM (Node Version Manager):

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash

Load NVM into the current session:

source ~/.bashrc

Install and use Node.js (replace 20.8.0 with the version you need):

nvm install 20.8.0
nvm use 20.8.0

Verify the Node.js installation:

node -v

3. Install Yarn

Install Yarn globally using npm:

npm install --global yarn

Verify the installation and check the path:

echo $PATH
yarn --version

Check Yarn in the global npm list:

npm list -g | grep yarn

4. Clone and Set Up the Project

Clone the project repository:

git clone https://github.com/acvid3/aws-ec2.git

Navigate to the project directory:

cd aws-ec2

Install project dependencies:

yarn install

Running the Project

After completing the setup, you can run the project using the appropriate start command, such as yarn start, depending on how your project is configured.


Follow these instructions to successfully set up and run your project on an AWS EC2 instance.

5. Configure Nginx for Port Redirection

Set up Nginx to redirect traffic from port 80 to port 3000, where the Node.js application runs:

sudo nano /etc/nginx/nginx.conf

Insert the following server block inside the http context:

server {
    listen 80 default_server;
    server_name _;

    location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

Save and close the file with Ctrl + O, Enter, and Ctrl + X. Then test and restart Nginx:

sudo nginx -t
sudo systemctl restart nginx

6. Manage the Application with PM2

Install PM2 to manage the application process:

npm install pm2@latest -g

Start the application with PM2:

cd ~/aws-ec2
pm2 start server.js --name "my-app"
pm2 save

Set up PM2 to boot at server startup:

pm2 startup

Now, the application will restart automatically if it crashes or the server reboots.

7. Access the Application

The application is now running and accessible at:

http://44.204.13.49/


By following these instructions, you will have a Node.js application running on an AWS EC2 instance, managed by PM2, and accessible via Nginx on the default HTTP port 80.

Make sure to replace the placeholder text server.js and "my-app" with the actual entry point and name of your application as needed.

Now you have a complete README.md that provides comprehensive instructions on setting up and running a Node.js application on AWS EC2 with Nginx and PM2, including how to access the deployed application.

aws-ec2's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.