Pages

Monday, May 13, 2024

Launching and Configuring EC2 Instances: A Practical Guide to CentOS, Ubuntu, Windows, and Nginx on AWS

Launching and Configuring EC2 Instances: A Practical Guide to CentOS, Ubuntu, Windows, and Nginx on AWS

Launching AWS Free Tier EC2 instances for CentOS, Ubuntu, and Windows, and configuring Nginx to start on a specific IP address (76.36.221.96) using the AWS Management Console involves several key steps. Here’s a step-by-step guide, including best practices for setup and security.

Step 1: Log into AWS Management Console

Start by logging into the AWS Management Console and navigate to the EC2 Dashboard.

Step 2: Launch Instances

For CentOS and Ubuntu:

  1. Select "Launch Instances" under the "Create Instance" section.
  2. Choose AMI: Search for the latest Free Tier eligible CentOS or Ubuntu AMIs in the Community AMIs. Note: CentOS images might be labeled under "Red Hat Enterprise Linux" or as "CentOS Stream".
  3. Choose Instance Type: Select a t2.micro for Free Tier eligibility.
  4. Configure Instance Details: Set network and subnet. Optionally enable "Auto-assign Public IP".
  5. Add Storage: Stick with the default unless specific needs dictate otherwise.
  6. Tag Instance: Enter a name tag for your instance, such as Name: MyCentOS or Name: MyUbuntu.
  7. Configure Security Group: Click "Create a new security group", name it, and set rules:
    • SSH (port 22) - Source: Anywhere or your IP for enhanced security.
    • HTTP (port 80) - Source: Anywhere.
    • HTTPS (port 443) - Source: Anywhere.
  8. Review and Launch: Review your settings, then click "Launch".
  9. Key Pair: Select an existing key pair or create a new one, then acknowledge that you have access to the selected key, and click "Launch Instances".

For Windows: Follow the same steps, but select a Free Tier eligible Windows AMI (e.g., "Microsoft Windows Server 2019 Base").

Step 3: Associate an Elastic IP

  1. Allocate Elastic IP: Go to the "Elastic IPs" section under "Network & Security", allocate a new Elastic IP, and associate it with your instance.
  2. Attach Elastic IP to Instance: If 76.36.221.96 is available in your account, associate it with the instance. If not, use the allocated Elastic IP from AWS.

Step 4: Connect to Instances and Install Nginx

Linux (CentOS, Ubuntu):

  • Connect: Use SSH to connect to the instance. For example:
ssh -i /path/to/your/key.pem ec2-user@your-elastic-ip

Install Nginx:

# CentOS sudo yum update -y sudo yum install nginx -y sudo systemctl start nginx sudo systemctl enable nginx # Ubuntu sudo apt update sudo apt install nginx -y sudo systemctl start nginx sudo systemctl enable nginx

Windows:

  • Connect: Use Remote Desktop to connect to the instance.
  • Install Nginx: Download and install Nginx for Windows.

Step 5: Verify Installation

  • Check Nginx: Access http://your-elastic-ip from a browser to see if Nginx is running.

Best Practices

  • Security: Limit SSH and RDP access to known IPs only.
  • Monitoring: Enable CloudWatch for monitoring instance performance and health.
  • Backups: Utilize EBS snapshots or AMI for backing up your instance and data regularly.
  • Update and Patch: Regularly update your instance's operating system and applications.
  • Scaling: Consider Auto Scaling to manage load and performance.

This guide provides a comprehensive approach to launching and managing EC2 instances via the AWS Console, ensuring they are securely configured and prepared for serving applications with Nginx.



No comments:

Post a Comment