Install LAMP Stack Using Cloud Formation
In this article, we will be launching a LAMP Stack Instance using Cloud Formation. For this we are using Ubuntu Server 14.04 LTS (PV) – ami-9a7724c8 (64-bit)
Steps to Launch:
1) Create a .json file
2) Open AWS Console
3) Browse to Cloudformation, CREATE STACK and upload the .json file
Create a .json file
{
"Resources" :
{
"WebServer":{
"Type": "AWS::EC2::Instance",
"Properties":{
"ImageId" : "ami-9a7724c8",
"KeyName" : "demo",
"InstanceType":"t1.micro",
"SecurityGroups" : [ "demo" ],
"UserData" : {"Fn::Base64" : {"Fn::Join" : ["", [
"#!/bin/bash\n",
"# Launching Instance",
"apt-get -y install apache2 \n",
"apt-get -y install mysql \n",
"apt-get -y install mysql-server \n",
"apt-get -y install php php5-mysql \n"
] ] } }
}
}
},
"Outputs":{
"WebsiteURL" : {
"Value" : { "Fn::Join" : ["", ["http://", { "Fn::GetAtt" : [ "WebServer", "PublicDnsName" ]}]] },
"Description" : "URL for newly created LAMP stack"
}
}
}
[/js]
[js] **Note: Keyname and Security groups must exists on your account [/js]
If everything goes well, you will get the the CREATE_COMPLETE message in the Status Tab. If any error occurs then a ROLLBACK event is invoked which will delete the stack.
Since we got the CREATE_COMPLETE message with a output parameter that we have defined in our json which returns the public DNS name of the Instance.
We can see the Public DNS is same.
To Terminate this Instance we can delete the stack from the Cloud Formation Wizard. Deleting the stack will terminate all the instances launched by that stack.
I appreciate your detailed information here but want to add some easy and helpful way to install LAMP CF on Amazon EC2. For that, you can use ready to run cloud image (AMI) available on AWS marketplace.
For that, go to AWS marketplace and search for LAMP cloudformation. You will get a list of this CF providers. Choose any one of them and follow the provided usage Instructions.
Here you can find the simple steps to setup LAMP CF on AWS