0

I'm trying to make a Launch Configuration for my AWS Cloud Environment.

I wan't to install httpd and start it up on the fly, when the autoscaling group spins up a new EC2 instance.

I can SSH into the instance manually and install httpd with: sudo yum update -y sudo yum install httpd -y sudo service httpd start

But I can't make it happen, with the Launch Configuration under Advance Details -> User Data sudo yum update -y sudo yum install httpd -y sudo service httpd start

Any ideas why it's not the same?

enter image description here

Update After adding #!/bin/bash as @Mark-B suggested, then service is kindda installed. It gives the following error when restarting the service. Maybe it could be a hint for you, to figure out what is wrong?

enter image description here

RedHawkDK
  • 119
  • 1
  • 4
  • 9

1 Answers1

2

User-data can be used for more than running startup scripts. To indicate to the cloud-init process that the user-data is a script, you need to add this as the first line of your user-data:

#!/bin/bash

Mark B
  • 183,023
  • 24
  • 297
  • 295
  • Hi Mark. That makes sense! Thanks. Any ideas, why the server still isn't starting up the same way, as when I start it up manually? sudo service httpd status --- > httpd (pid 2734) is running... so it apparently looks fine... – RedHawkDK Nov 23 '18 at 16:18
  • @RedHawkDK that second issue looks like a duplicate of this: https://stackoverflow.com/questions/5856205/could-not-reliably-determine-the-servers-fully-qualified-domain-name – Mark B Nov 23 '18 at 19:50