RedHawkDK
RedHawkDK

Reputation: 139

Install and Start httpd in AWS Launch Configuration

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

Upvotes: 0

Views: 826

Answers (1)

Mark B
Mark B

Reputation: 200562

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

Upvotes: 2

Related Questions