简体   繁体   中英

AWS EC2 instance showing Apache test page instead of webpage

I am new to AWS and recently I was trying to access a webpage using an EC2 instance. I uploaded the webpage using the following bash commands in the User Data field while creating the instance:

#!/bin/bash
yum update -y
yum -y install httpd
systemctl enable httpd
systemctl start httpd
echo '<html><h1>Sample Webpage</h1></html>' > /var/www/html/index.html

I noticed that the public IP address of the instance directed me to the Apache Web Server's test page when the names of the security group and the instance were different, but to the desired webpage when the names were same .

Could anyone please explain why is it so?

There is nothing wrong with your user_data. It works exactly as expected. Whatever you are checking, does not involve this code, thus please double check your instances and their user data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM