By using AWS re:Post, you agree to the Terms of Use

Why Do My EC2 T2.Micro Instances Come In With No HTTPD?

0

I am studying for SAA and am just trying to get 3 EC2 T2.Micro Instances workking for load balancing. I've got one working and 'In Service.' When I try to get any other one working, whether from scratch but using the same security group info and everything, or templating the working one using 'launch one like this', they come in out of service. When I connect to the instance using ECM and do a 'service httpd status', I get 'httpd.service could not be found.' Note that on the working Instance, it tells me that it's working.

What is going on? What is the cause of this?

2 Answers
0

When you "launch more like this", the new instance is launched from the original AMI that was used to launch the first instance. Therefore, if you have made any subsequent updates to the first instance (such as installing and starting httpd), this will not be reflected in the new instance. The way round this is to create an instance using an AMI, and add "User Data" to install the httpd software. The "launch more like this" will then pick up the original AMI and the User Data. (Reference for User Data: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html)

answered 8 months ago
  • Thanks, I should've mentioned that I had pre-loaded, in the creating of the instance, the following user data per the slides for the class:

    yum update -y yum install -y httpd.x86_64 systemctl start httpd.service systemctl enable httpd.service echo "Hello World from $(hostname -f)" > /var/www/html/index.

    Unfortunately, none of this actually 'took.' When I would check to see if the HTTP daemon was running with a 'systemctl status httpd', HTTP not only wasn't running - it wasn't even loaded. And even when I ran the commands manually, the file 'index' wasn't even there. I had to do all of this manually, including VI'in the file and set the health check to '/' because, even when the file was present, it still wouldn't read it. Some machines just come into your network wanting to go 15 rounds with you. This simple thing took me about 5 hours to figure out and get to work. I hope AWS isn't this buggy in real life. If it is, I don't know how a company functions with this kind of trouble just getting a machine to pass a health check.

    I appreciate the response.

0

I would suggest taking a look here: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html#user-data-launch-instance-wizard

This has an example user data script that you can use that will accomplish what you want on an Amazon Linux 2 AMI. I'm assuming you're using Amazon Linux 2 for this setup (if not, let me know)

From your user data script you provided above, you're not telling the user data what scripting language your using so it's not sure what the commands are you're sending. Try defining bash and see how that helps.

EXPERT
answered 8 months ago
  • Thanks! This looks like it could work. Your assumption about the type of AMI is correct. I have at least 1-2 more instances to create before I can do the next series of labs. Unfortunately, I'll have to wait bec AWS tech support has seen fit to lock my account. They think I'm being hacked. No, it's you guys' crappy autofill in my browser, where half the credential info is for my root account and the other half is for my IAM account. Stop doing that, AWS, and maybe I'll stop putting in the wrong cred's that look like someone's trying to break in.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions