I try to make sure and make it as clear as possible, so let me know if something is not clear, and perhaps I will even make a video of it
1. Create your server normally, even if you don't need to have Ubuntu, you can also use any Linux from Amazon.
2. Make sure you put your .pem in the folder where you will run your SSH. In my case, I really like using Visual Studio.
3. Connect your server using SSH
code:
chmod 400 "dimas-mbp.pem"
ssh -i "dimas-mbp.pem" ec2-user@ec2-3-87-117-248.compute-1.amazonaws.com
4. Install the dependencies. I am following this channel https://www.sammeechward.com/deploying-full-stack-js-to-aws-ec2,
but he is using Ubuntu, so for linux amazon, since its debian the following task is change into
code:
sudo yum update -y
sudo dnf upgrade -y
sudo yum install git -y
Install node JS
curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash -
sudo yum install -y nodejs
sudo dnf module list nodejs
sudo dnf module enable nodejs
sudo dnf install -y nodejs
5. After all going well, make sure you clone your from github to the ec2
git clone https://github.com/dimasmukhlas/code-canvas-tool.git myapp
cd myapp
6. Run the dependencies
code:
npm i
sudo npm install -g npm@11.5.2
npm run dev
7. Add new security to make sure that you able to run the server by let 8080 port goes in TCP request
it running voila
🚀 Deploy Node.js App on Amazon Linux EC2
1. Create Your Server
Create your EC2 server normally. You don’t need to use Ubuntu, you can also use Amazon Linux.
2. Add Your .pem Key
Make sure you put your .pem file in the folder where you will run your SSH. (I like using Visual Studio Code).
3. Connect to Your Server
ssh -i mykey.pem ec2-user@your-ec2-ip
4. Install Dependencies
I followed this guide: Sam Meech-Ward tutorial. But since Amazon Linux is not Ubuntu, use these commands instead:
sudo yum update -y
sudo dnf upgrade -y
sudo yum install git -y
Install Node.js
curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash -
sudo yum install -y nodejs
# On Amazon Linux 2023
sudo dnf module list nodejs
sudo dnf module enable nodejs:20
sudo dnf install -y nodejs
5. Clone Your Repository
git clone https://github.com/dimasmukhlas/code-canvas-tool.git myapp
cd myapp
6. Install Node Dependencies
npm install
sudo npm install -g npm@11.5.2
npm run dev
7. Open Security Group Port
In your AWS Security Group, allow TCP requests on port 8080 so your server is accessible.
✅ That’s it — your server is running! 🎉



0 Comments