In the world of cloud computing, Amazon Web Services (AWS) stands out as a powerful platform for developers and businesses. One of the most fundamental services offered by AWS is Amazon EC2 (Elastic Compute Cloud), which allows you to create virtual servers in the cloud. This post will guide you through the process of creating an EC2 instance, installing the Apache web server, and connecting to it using PowerShell.
Step 1: Creating an EC2 Instance
1.Log in to AWS Management Console:
Go to the AWS Management Console and log in with your credentials.
2.Launch an EC2 Instance:
- In the console, find and select EC2 under the "Compute" section.
- Click on Launch Instance.
- Choose an Amazon Machine Image (AMI). For this tutorial, select an Amazon Linux 2 AMI or Ubuntu Server AMI.
- Select an instance type (e.g., t2.micro for free tier eligibility) and click Next: Configure Instance Details.
3.Configure Instance Details:
- Configure settings as needed (default settings work for most users).
- Click Next: Add Storage, then proceed through the next steps until you reach the Review and Launch section.
4.Launch the Instance:
- Review your settings and click on Launch.
- You will be prompted to select or create a key pair. If you don’t have one, create a new key pair, download it, and keep it safe. This key pair is essential for connecting to your instance.
Step 2: Installing Apache Web Server
1.Connect to Your EC2 Instance:
- Open PowerShell on your local machine.
- Use the following command to connect via SSH (replace with your key file path and or with the appropriate username based on your AMI):
ssh -i "<path-to-key>.pem" ec2-user@<public-ip-address>
2.Update Package Repository:
Once connected, update your package repository:
sudo yum update -y # For Amazon Linux
sudo apt update # For Ubuntu
3.Install Apache:
Install Apache using the following command:
sudo yum install httpd -y # For Amazon Linux
sudo apt install apache2 -y # For Ubuntu
4.Start Apache Service:
Start the Apache service and enable it to run on boot:
sudo systemctl start httpd # For Amazon Linux
sudo systemctl start apache2 # For Ubuntu
sudo systemctl enable httpd # For Amazon Linux
sudo systemctl enable apache2 # For Ubuntu
5.Adjust Firewall Settings:
- Ensure that HTTP traffic is allowed through your instance's security group settings in the AWS console.
- You may need to add a rule that allows inbound traffic on port 80 (HTTP).
Step 3: Verify Apache Installation
1.Access Your Web Server:
- Open a web browser and enter your EC2 instance's public IP address.
- If everything is set up correctly, you should see the default Apache test page.
Conclusion
Congratulations! You have successfully created an EC2 instance, installed the Apache web server, and connected using PowerShell. This setup serves as a foundation for hosting web applications on AWS.
Feel free to share your experiences or ask questions in the comments below!
Top comments (0)