AWS
🌐 AWS Server Setup & Website Deployment
1. AWS Login 🚪
Account Types
Root User: Main account holder, manages everything (email & password).
IAM User: Limited permissions for security (can only perform specific tasks).
2. Log in to AWS Console 💻
Log in to AWS Management Console.
Region Selection: Set to London (or choose your preferred region).
3. Launch an EC2 Instance 🚀
Steps:
Navigate to EC2 Service:
Console > EC2 > Instances > Launch Instance.
Instance Name and Tags:
Provide a name for the server, e.g., "Frontend Server", "Backend Server".
Application and OS Images (Choose the OS for your server):
Options:
Ubuntu (Recommended) 🐧.
Amazon Linux.
macOS.
Example:
Select Ubuntu Server 22.04 LTS (HVM), SSD Volume Type.
4. Instance Details ⚙️
AWS Architecture Overview:

The architecture comprises:
Virtual Private Cloud (VPC) to isolate resources.
EC2 Instances to host the server.
S3 for object storage.
Security Groups for managing inbound/outbound traffic.
Select 64-bit (x86) for compatibility.
Instance Type
t2.micro: Suitable for small web apps, Free Tier (React Apps).
t2.small: Suitable for backend services (Paid).
Key Pair (Login) 🔑
Click on Create new key pair.
Provide a name for the project.
Select File Type: .pem and Download.
Save it securely to access the server later.
Network Settings 🌐
Allow SSH Traffic from anywhere (tick).
Allow HTTPS and HTTP Traffic from the internet (tick).
Configure Storage 💾
Allocate 30 GB (default, gp2 SSD).
Advanced Details (Optional) ⚙️
No changes required here.
Summary 📝
Review all settings:
Number of instances: 1 or more based on requirements.
AMI: Ubuntu 22.04 LTS.
Instance Type: t2.micro or t2.small.
5. Create and Connect to EC2 Instance 🔌
Create the EC2 Instance 🖥️
Click Launch.
Connect to the Instance 📡
Create IAM Role: Attach
AmazonSSMFullAccess
for secure access.Enable Fleet Manager host.
Connect Using SSH 🔐
chmod 400 project-key.pem
ssh -i "project-key.pem" ubuntu@<public-ip-address>
6. Install Dependencies for Web Application ⚙️
Become Super User
sudo su
Install Node.js & NPM 🌐
Follow the guide here.
Use the first option command.
After installing Node.js:
npm install -g n
n lts
If you encounter errors, refer to the Node.js Package Manager Guide.
Install MongoDB 💾
Follow this tutorial.
If there are issues:
Download
libssl1.1
:
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb
sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb
sudo apt-get install -y mongodb-org
Install Nginx 🌐
Follow this tutorial.
Use
"Nginx Full"
for firewall settings:
shCopy codesudo ufw allow 'Nginx FULL'
sudo ufw enable
sudo ufw status
sudo ufw reload
Install PM2 🔄
sudo npm install pm2 -g
7. Upload Application Code 📁
Upload Frontend & Backend Code
cd /var/www/html/
Install NVM (Node Version Manager) 🌐
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
source ~/.bashrc
nvm install --lts
npm install -g npm
npm install
Site Configuration for Nginx ⚙️
Unlink Default Config File
cd /etc/nginx/sites-available/
sudo unlink /etc/nginx/sites-available/default
Create New Config File for Frontend & Backend 🖊️
Frontend Configuration Example:
server {
root /var/www/html/frontend-build/;
index index.html;
server_name yourdomain.com;
location / {
try_files $uri /index.html;
}
}
Backend Configuration Example:
server {
listen 80;
server_name backend.yourdomain.com;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
Enable Configuration
sudo ln -s /etc/nginx/sites-available/example.conf /etc/nginx/sites-enabled
Test and Restart Nginx ⚙️
sudo nginx -t
sudo systemctl restart nginx
8. Set Up SSL 🔒
Install Certbot:
shCopy codesudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt install certbot python3-certbot-nginx
Generate SSL Certificate:
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
Renew Certificate:
sudo certbot renew --dry-run
9. Additional Configurations 🛠️
Start Services
sudo systemctl start nginx
sudo systemctl start mongod
Check Service Status
sudo systemctl status nginx
sudo systemctl status mongod
Add IAM Role for SSM 📊
Assign SSM Administrator access to connect easily via AWS Systems Manager.
10. DNS Setup 🌍
A Records and CNAME
Main Website: Use A Record pointing to instance IP.
Subdomain (same instance IP): Use CNAME Record.
Different IP: Use A Record.
11. Extra Commands & Tips 💡
List PM2 processes:
pm2 list
Check Certbot Certificates:
certbot certificates
If stopping and restarting the instance, update DNS with the new IP address.
Conclusion 🎉
AWS provides powerful and flexible tools to build scalable and secure infrastructure for your website. With these steps, you're on your way to mastering AWS deployments!
Last updated
Was this helpful?