Step by step guide for installing LAMP stack on AWS EC2 instance
chiragchamoli.com
chiragchamoli.com
What you need to do instead is setup an auto-scaling group that automatically launches a new EC2 instance to replace the terminated one. You also need to set up boot scripts that automatically configure the newly launched instance to run your app, or alternatively create a custom AMI image that's preconfigured to run it on boot.
And if you store stateful data (like the MySQL in LAMP), you need to setup boot scripts to attach a EBS volume to store the data on. Or alternatively just use RDS which does it for you.