Deploy a Node.js server to AWS EC2
-
Ensure you have AWS account
-
Ensure you have your access and secret keys
-
Ensure repo has server setup but has no database
-
PORT is set in .env file
-
Zip all files together for application, except package-lock.json and node_modules folder
-
In Elastic Beanstalk console - create new application
-
Select create new application
-
Give the application a name
-
Select platform: Node.js
-
Select upload your code, and upload the zipped file
-
Make sure you have AWS CLI and EB CLI installed with access and secret key
-
run
eb init
from the repo you want to upload -
select all the initialization options that you want
-
run
eb create
with the name of the env you want to create -
go check AWS to see if the app is up and running
-
Clone down the repository
-
Run the command
npm install
-
Create a
.env
file withPORT
variable
- Run the command
npm test
to test the server
-
To run the server locally, run
nodemon
-
Open up your browser to the localhost you set your
PORT
variable to