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 πŸ’»

3. Launch an EC2 Instance πŸš€

Steps:

  1. Navigate to EC2 Service:

    • Console > EC2 > Instances > Launch Instance.

  2. Instance Name and Tags:

    • Provide a name for the server, e.g., "Frontend Server", "Backend Server".

  3. 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) πŸ”‘

  1. Click on Create new key pair.

  2. Provide a name for the project.

  3. 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 πŸ“‘

  1. Create IAM Role: Attach AmazonSSMFullAccess for secure access.

  2. Enable Fleet Manager host.

Connect Using SSH πŸ”

6. Install Dependencies for Web Application βš™οΈ

Become Super User

Install Node.js & NPM 🌐

  1. Follow the guide here.

  2. Use the first option command.

  3. After installing Node.js:

Install MongoDB πŸ’Ύ

Follow this tutorial.

If there are issues:

  1. Download libssl1.1:

Install Nginx 🌐

  1. Follow this tutorial.

    • Use "Nginx Full" for firewall settings:

Install PM2 πŸ”„

7. Upload Application Code πŸ“

Upload Frontend & Backend Code

Install NVM (Node Version Manager) 🌐

Site Configuration for Nginx βš™οΈ

Unlink Default Config File

Create New Config File for Frontend & Backend πŸ–ŠοΈ

  1. Frontend Configuration Example:

  1. Backend Configuration Example:

Enable Configuration

Test and Restart Nginx βš™οΈ

8. Set Up SSL πŸ”’

  1. Install Certbot:

  1. Generate SSL Certificate:

  1. Renew Certificate:

9. Additional Configurations πŸ› οΈ

Start Services

Check Service Status

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:

  • Check 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?