Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm about to start using AWS for the first time. From what I understood, when you terminate an instance or start a new one, all the data is lost. For user data I understand you are supposed to use cloud storage such as S3. That's ok.

Now what about all the configurations? Say I spend 2 hours setting up all the apache and PHP configuration or whatnot. How do I make sure it's still there when I terminate an instance, or start a new one?

Secondly, what about my actual app, the PHP code in my case, as well as the file permissions needed to run it? What happens when I terminate the instance? What if I have 3 instances and make changes to my code?

Sorry very new to this whole concept.


share|improve this question
If you use EBS volumes, then the data is not lost. You can use EBS and S3. – Andrew Smith Oct 23 '12 at 17:21
up vote 1 down vote accepted

Create an EBS volume and attach it to your instance. After you install your services (e.g. Apache, MySQL, PHP, etc) move the respective files to your EBS storage.

For example, I run Ubuntu on my instances and therefore all of the necessary configuration information for each service is contained in a respective directory under /etc (e.g. /etc/apache2, /etc/php, and so on). After mounting an EBS volume to /vol I then moved the /etc/{service} directory to /vol. So PHP went from /etc/php5 to /vol/etc/php5. I then symlinked /etc/php5 to /vol/etc/php5. The only "gotcha" is with MySQL you should also do the actual data directory of /var/lib/mysql as well.

Now if my instance dies or I terminate it all of the configurations are saved on the EBS, which I can then clone or attach to any other instance. Since I also placed /var/www/ on the EBS volume my websites and all their data are there as well.

share|improve this answer
Matt Houser above wrote that in both cases terminating the instance will erase data. It seems to contradict your answer, or are you saying something different? – nute Oct 24 '12 at 7:39
Matt Houser is incorrect that EBS data is lost upon termination of the instance. The only way that EBS data is lost is when you destroy the EBS volume itself. Please see and specifically the… section. – Daemon of Chaos Oct 24 '12 at 14:24
I was unclear. By default, the root ebs volume will be deleted when you terminate the instance. Unless you modify the volume attachment to not delete the volume upon termination, you will lose data. – Matt Houser Oct 24 '12 at 23:47
The best way to do it is as I suggested and create a separate EBS volume that your data and configuration information is stored on. This type of volume is not affected by the status of the instance. – Daemon of Chaos Oct 25 '12 at 3:08

There are 2 types of EC2 instances: (a) Instance Store - This type of instance has it's root volume on a hardware hard drive. You cannot stop this type of instance, it can only be terminated. When terminated, all data on that hard drive is lost. (b) EBS-backed - This type of instance has it's root volume on an EBS volume. EBS volumes are persisted and stored away from the EC2 instance. These types of instances can be stopped and restarted without loss of data from the EBS volumes.

EBS-backed instances are the preferred instance types because of the ability to backup and restore the volumes and the ability to stop and start your instances.

In either case, data is lost of you terminate your instance. You can create AMI images of your EC2 instances, which can then be used to create new copies of your instance.

share|improve this answer
What is the difference between terminating and stopping? Do I continue to pay in one of the cases? Do I ever need to terminate? – nute Oct 24 '12 at 7:40
Stopping is like turning off your server. You can turn it back on later. Terminating is like erasing the hard drive: it's gone forever. – Matt Houser Oct 24 '12 at 23:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.