You want an EC2 instance that serves web pages, not mysterious error pages at 3 a m. This short tutorial walks through picking an AMI and instance type configuring VPC and subnet rules creating a security group provisioning a key pair and deploying Apache on the instance. Think of it as the bare metal bits of cloud deployment without the hand wringing.
For testing use a modern Amazon Linux or Ubuntu AMI. If you do not want to pay much use t2 or t3 class instances for small workloads. For production scale up to the compute family that matches your CPU and memory needs. Your choice affects cost and performance so pick with a little thought not just optimism.
Either pick an existing VPC or make a new one for isolation. Choose a public subnet if you want a public IP and direct internet access via an internet gateway. Choose a private subnet if you plan to place the server behind a load balancer or NAT gateway. Yes the internet can wait while you do this properly.
Security groups are stateful and act like the polite bouncer for your instance. At a minimum add rules that allow:
Narrow SSH to your IP range unless you enjoy random logins from strangers and bots. For extra safety consider restricting HTTP to a load balancer or using HTTPS with a certificate.
Generate a key pair in the AWS console or upload your public key when launching. Download the private key and store it somewhere safe. If you lose it you lose easy SSH access unless you set up other access methods like a Systems Manager session or a rescue image. Also do not name the key pair "password123" unless you like irony.
Once the instance is running find the public IP or public DNS and connect with SSH using the private key. Example for Amazon Linux use the right username for your AMI. Typical commands look like this
ssh -i mykey.pem ec2-user@PUBLIC_IP
On Ubuntu the username is often ubuntu. If SSH fails check the security group rules and the instance public IP. Also make sure the key permissions are correct locally with chmod 400 mykey.pem.
Update packages and install Apache based on your Linux family. Commands you might run include these. Copy them into your terminal and try not to panic.
# Debian and Ubuntu family
sudo apt update && sudo apt install -y apache2
# RHEL and Amazon Linux family
sudo yum update -y && sudo yum install -y httpd
# Start and enable the service
sudo systemctl start apache2 # Debian variants
sudo systemctl enable apache2
sudo systemctl start httpd # RHEL variants
sudo systemctl enable httpd
Visit the instance public IP in a browser and you should see the Apache default page. If not check firewall and security group settings and the service status.
If you want to move beyond minimal setup consider these improvements
There you go a functional EC2 server running Apache with basic VPC and security group setup. It is not a fortress yet but it will deliver pages and let you iterate toward a properly hardened cloud deployment. Now go make something people will actually read.
I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!
This is a dedicated watch page for a single video.