DEV Community

Ashiq Omar
Ashiq Omar

Posted on

EC2 LAUNCHING

Let’s go step by step and launch a simple web server on AWS.

Step 1: Launch an EC2 Instance
Go to the AWS Console open EC2 and click on Launch Instance.
Now configure the instance:

Name: my-web-server
AMI: Amazon Linux 2, which is beginner-friendly
Instance Type: t2.micro since it comes under the free tier

Step 2: Choose a Key Pair
You need a key pair to securely connect to your instance.
You can either create a new one or use an existing key pair.
Make sure to download the .pem file when creating it, because you’ll need it later to connect.

Step 3: Configure Network Settings
Allow the following ports:
SSH (port 22) for logging into the server
HTTP (port 80) so your website can be accessed from a browser

Step 4: Launch the Instance
Click on Launch Instance.
Your server will now be created and started.

Step 5: Connect to the Instance
There are two easy ways to connect:

First option:
Use EC2 Instance Connect directly from the AWS Console. This is the easiest method.

Second option:
Use your terminal with the key pair file you downloaded:

ssh -i your-key.pem ec2-user@<public-ip>
Enter fullscreen mode Exit fullscreen mode

Step 6: Install a Web Server
Once connected, install Apache on your instance:

sudo yum update -y
sudo yum install httpd -y
Enter fullscreen mode Exit fullscreen mode

Step 7: Start the Web Server
Start the Apache service and enable it so it runs automatically:

sudo systemctl start httpd
sudo systemctl enable httpd
Enter fullscreen mode Exit fullscreen mode

Step 8: Create a Simple Web Page
Now add a basic web page:

echo "Hello from EC2" | sudo tee /var/www/html/index.html
Enter fullscreen mode Exit fullscreen mode

Step 9: Get the Public IP
Go to the EC2 dashboard and copy the public IP address of your instance.

Step 10: Access from Your Browser
Open your browser and enter:

http://<your-public-ip>
Enter fullscreen mode Exit fullscreen mode

If everything is set up correctly you will see:
Hello from EC2

Top comments (0)