I am setting up new EC2 instances, and I want to be able to see hello world, the AZ and the IP address displayed. It only shows the apache start page.
I have preloaded the code listed below in the user startup section of EC2, in the advanced details, user data, and have "added as text" clicked and selected.
I copied this text off of a training video from udemy, Ultimate AWS Certified Solutions Architect Associate 2019 by Stephane Maarek, Lesson 60, rt53 EC2 setup at approx the 1:11 mark.
#!/bin/bash
yum update -y
yum install -y httpd
systemctl start httpd.service
systemctl enable httpd.service
EC2_AVAIL_ZONE=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone)
echo "<h1>Hello World From Rokkitt at $(hostname -f) in AZ $EC2_AVAIL_ZONE </h1> > /var/www/html/index.html
I am just getting the apache start page, not the hello world and user meta data info. thank you, I am just starting so I apologize for any mistakes
You aren't closing your double quotes when echoing html into the index.html. Try the below.
#!/bin/bash
yum update -y
yum install -y httpd
systemctl start httpd.service
systemctl enable httpd.service
EC2_AVAIL_ZONE=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone)
echo "<h1>Hello World From Rokkitt at at $(hostname -f) in AZ $EC2_AVAIL_ZONE </h1>” > /var/www/html/index.html
ok, thank you ...
after carefully looking, I missed the closing quote as stated above. thanks! also, I spent time making sure the index.html file was present with the cat command with the string /var/www/html/index.html and it showed me the contents of that file. thank you again!
also, I set up my nacl and security group and internet gateway IGW to allow icmp traffic so I could ping the instance as well.
thanks!
1082
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.