I would like to launch a LAMP stack with Autoscaled EC2 instances through CloudFormation template. Whenever I try it, stack is built successfully but when I go onto the website, it gives me a message that app does not support older versions of PHP.
Now, when I searched for this problem online, I found one answer that suggested installing newer versions of httpd and php through yum. I tried that directly on the EC2 linux terminal and it worked, I could now access the website successfully. The thing is, I want these updated versions to be installed directly in the template. For this purpose I replaced this code within AutoScaling::LaunchConfiguration:
"setup" : {
"packages" : {
"yum" : {
"nfs-utils" : [],
"httpd" : [],
"php" : [],
"mysql" : []
}
},
with:
"setup" : {
"packages" : {
"yum" : {
"nfs-utils" : [],
"httpd24" : [],
"php72" : [],
"mysql" : []
}
},
This causes the stack to fail to create AutoScalingGroup which has the LaunchConfiguration as param, with an error stating "Received 0 SUCCESS signal". Here's my Properties of LaunchConfiguration:
"Properties": {
"AssociatePublicIpAddress" : true,
"ImageId" : { "Fn::FindInMap" : [ "AWSRegionArch2AMI", { "Ref" : "AWS::Region" },
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
"InstanceType" : { "Ref" : "InstanceType" },
"SecurityGroups" : [ {"Ref" : "WebServerSecurityGroup"} ],
"KeyName" : { "Ref" : "KeyName" },
"IamInstanceProfile" : { "Ref" : "CloudWatchPutMetricsInstanceProfile" },
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bash -xe\n",
"yum update -y aws-cfn-bootstrap\n",
"/opt/aws/bin/cfn-init -v ",
" --stack ", { "Ref" : "AWS::StackName" },
" --resource LaunchConfig ",
" --configsets app_install ",
" --region ", { "Ref" : "AWS::Region" }, "\n",
"/opt/aws/bin/cfn-signal -e $? ",
" --stack ", { "Ref" : "AWS::StackName" },
" --resource WebServerGroup ",
" --region ", { "Ref" : "AWS::Region" }, "\n"
]]}}
}
Any ideas why it doesn't work? Any suggestions what I can do to actually install newest httpd and php directly through the template? Should I remove packages section and just put script for installing httpd and php directly in the UserData?
/var/log/cloud-init-output.log
and other similar log files? – Marcin