Unable to view the webpage hosted on my ec2 instance
I wanted to launch a little static website on an EC2 instance and I followed the following steps:
- launched a t2.micro instance using console in us-east-1 region
- attached an existing security group which allows http request, https and ssh.
- logged in my ec2 through SSH and changed it into an apache web server using following commands:
commands:
#bin/bash
sudo su
yum update -y
yum install httpd -y
cd /var/www/html
-
Then I wrote a hello world html code in index.html file and started my web service
service httpd start
chkconfig on
Even after following all the above steps, when I open try to access the webpage by going to the public ipv4 address of my ec2 instance, I am getting a timout error.
Any idea what I might be missing here?
Thank you.
You can try creating new EC2 instance like below
-
Lunch the same type of instance
-
Add below script in user data to create HTML page
#!/bin/bash
Use this for your user data (script from top to bottom)
install httpd
yum update -y yum install -y httpd systemctl start httpd systemctl enable httpd echo "
Hello World - $(hostname -f)
" > /var/www/html/index.html -
After launching EC2, open that security group and add below HTTP rule
- At the end, manually type HTTP://your public address. sometimes by default its shows with HTTPS so just ensure you are typing HTTP only.