![]()
EC2 for Beginners: Launching Your First Virtual Server (Step-by-Step Tutorial)
Welcome to the world of cloud computing! If you’re looking to launch your first virtual server and dive into Amazon Web Services (AWS), you’ve come to the right place. This guide will walk you through launching an Amazon Elastic Compute Cloud (EC2) instance, step-by-step, using simple language and clear instructions. No prior AWS experience is necessary!
What is EC2, anyway?
Think of EC2 as renting a computer in the cloud. Instead of buying and maintaining your own physical server, you can rent one from AWS for a specific amount of time. This allows you to:
- Develop and test applications: Create a sandbox environment without worrying about your local machine.
- Host websites and applications: Make your project accessible to the world.
- Process large datasets: Leverage the power of the cloud for demanding tasks.
- Experiment with different operating systems: Explore different Linux distributions or Windows Server without installing them on your own hardware.
Let’s Get Started!
Here’s a step-by-step guide to launching your first EC2 instance:
Prerequisites:
- An AWS account. If you don’t have one, you can sign up for a free tier account at AWS Website. (Note: some features may incur charges even with the free tier).
- A web browser (Chrome, Firefox, Safari, etc.).
Step 1: Log in to the AWS Management Console
- Open your web browser and go to the AWS Management Console: AWS Management Console
- Enter your AWS account email address and password and click “Sign in”.
Step 2: Navigate to the EC2 Service
- In the AWS Management Console, you’ll see a search bar. Type “EC2” and select “EC2” from the search results.
- This will take you to the EC2 Dashboard.
Step 3: Launch an EC2 Instance
- On the EC2 Dashboard, click on the blue button labeled “Launch Instance”.
- You will be guided to the “Choose an Amazon Machine Image (AMI)” page.
Step 4: Choose an Amazon Machine Image (AMI)
An AMI is a template that contains the operating system, software, and configuration settings for your instance.
- Quick Start AMIs: AWS offers pre-configured AMIs. For beginners, we recommend choosing a free tier eligible AMI like “Amazon Linux 2023 AMI” or “Ubuntu Server 22.04 LTS.” Type these names in search box or browse the options.
- Click “Select” next to the AMI you want to use.
Step 5: Choose an Instance Type
The instance type defines the hardware configuration of your EC2 instance, including CPU, memory, and network performance.
- You’ll be presented with a list of instance types. For free tier eligibility and for testing, choose
t2.micro. It’s usually listed under “Free tier eligible” section. - Select the
t2.microinstance type and click “Next: Configure Instance Details”.
Step 6: Configure Instance Details (Optional for Beginners)
This screen allows you to configure advanced settings for your instance. For your first instance, you can generally leave the default settings. You might want to review the following:
- Number of instances: Set this to “1” if you only want to launch one instance.
- Network: Leave this as the default VPC (Virtual Private Cloud). This creates a logical isolated network.
- Subnet: Leave this as “No preference”. AWS will assign your instance to an available subnet in the VPC.
- Auto-assign Public IP: Make sure this is set to “Enable”. This is crucial for connecting to your instance.
Click “Next: Add Storage”.
Step 7: Add Storage
This screen allows you to configure the storage for your instance.
- The default storage volume (usually 8GB for free tier AMIs) is sufficient for most basic projects.
- You can increase the size of the volume if needed, but be aware of any potential charges.
- Click “Next: Add Tags”.
Step 8: Add Tags (Optional)
Tags are key-value pairs that you can use to organize and identify your EC2 instances. This is really helpful if you are managing a lot of instances.
- Click “Add Tag”.
- In the “Key” field, enter “Name”.
- In the “Value” field, enter a descriptive name for your instance, such as “MyFirstEC2”.
- Click “Next: Configure Security Group”.
Step 9: Configure Security Group
A security group acts as a virtual firewall for your instance, controlling the traffic that is allowed to enter and exit the instance.
- Assign a security group: Choose “Create a new security group”.
- Security group name: Enter a name, such as “my-first-security-group”.
- Description: Enter a description, such as “Security group for my first EC2 instance”.
- Rule 1 (SSH): SSH access is necessary to connect to your Linux instance using a terminal.
- Type: Select “SSH”.
- Protocol: TCP should be preselected.
- Port Range: 22 should be preselected.
- Source: Select “My IP” to allow only your current IP address to connect to the instance. Important: For testing purposes, you can set the “Source” to “Anywhere” (0.0.0.0/0), but this is not recommended for production environments due to security risks.
- Rule 2 (HTTP): For serving web pages, let’s add HTTP access.
- Type: Select “HTTP”.
- Protocol: TCP should be preselected.
- Port Range: 80 should be preselected.
- Source: “Anywhere” (0.0.0.0/0) is fine for testing purposes.
- Rule 3 (HTTPS): If you plan to use HTTPS for secure website access
- Type: Select “HTTPS”.
- Protocol: TCP should be preselected.
- Port Range: 443 should be preselected.
- Source: “Anywhere” (0.0.0.0/0) is fine for testing purposes.
- Click “Review and Launch”.
Step 10: Review and Launch
- Review your instance configuration. Make sure everything is as expected.
- Click “Launch”.
Step 11: Key Pair
A key pair is used to securely connect to your EC2 instance.
- Select an existing key pair or create a new key pair: Since this is your first time, select “Create a new key pair”.
- Key pair name: Enter a name for your key pair, such as “MyFirstKeyPair”.
- Key pair type: Select RSA
- Private key file format: Select .pem.
- Click “Download Key Pair”. Important: Save the downloaded
.pemfile in a safe location. You will need this file to connect to your instance. You cannot download this key again. - Click “Launch Instances”.
Step 12: Monitor Instance Launch
- You’ll be redirected to a “Launch Status” page. You can click on the instance ID link to view the details of your instance.
- Your instance will transition through different states (pending, running, etc.). It can take a few minutes for the instance to be fully launched.
- Wait until the instance status is “Running” and the status checks are “2/2 checks passed”.
Congratulations! You have successfully launched your first EC2 instance!
Next Steps:
- Connect to your Instance: Learn how to connect to your instance using SSH. The steps for connecting using SSH will vary depending on your operating system (Windows, macOS, Linux). AWS provides detailed instructions for connecting to your instance on the EC2 console page for your running instance.
- Install Software: Install the software you need for your project (e.g., web server, database).
- Explore AWS Services: Discover other AWS services like S3 (storage), RDS (databases), and Lambda (serverless functions).
Important Notes:
- Security: Always keep your key pair safe. Do not share it with anyone.
- Pricing: Be aware of the pricing for different instance types and storage options. Regularly check your AWS bill to avoid unexpected charges.
- Stopping vs. Terminating: Stopping an instance pauses it, but you are still charged for storage. Terminating an instance deletes it, and you stop incurring charges (except for any stored data).
- Clean Up: Remember to stop or terminate your instance when you are finished with it to avoid incurring unnecessary charges.
This guide provides a basic introduction to launching an EC2 instance. There are many more advanced features and configurations you can explore as you become more comfortable with AWS. Happy cloud computing!