Old tutorial: launching TurnKey AMIs with the Amazon Web Console

Warning: this is an old tutorial from before we created TurnKey Hub, a web service which makes it much easier to launch and manage TurnKey Linux appliances in the Amazon EC2 cloud. TurnKey Hub automatically takes care of the many potentially confusing and frustrating details described below.

If you're not using TurnKey Hub, you'll need a free subscription to TurnKey's AMIs (Amazon Machine Images) to continue...

Table of contents


EC2 has many powerful features, which can make it confusing for new users.

This tutorial does not assume previous experience with EC2. We'll show how to launch the TurnKey LAMP appliance on EC2 using Amazon's management console but the principles are the same even if you use a different interface such as the ElasticFox FireFox extension or Amazon's command line API.

Launching an instance

Log into the Amazon web console.

Launch instance wizard

Select the region where you want to launch an instance (us-east-1, us-west-1, eu-west-1).

Click on the Lauch Instances button which launches the Launch Instance Wizard.

Select the community AMIs tab. Entering "turnkeylinux" into the text box will give you a list of available TurnKey Linux appliances.

To select the AMI you would like to launch, click select or enter its codename (e.g., turnkey-lamp).
Note that old AMIs have the turnkey-ami- prefix while new AMIs have the turnkeylinux- prefix:


Create SSH keypair

If you haven't setup an SSH keypair, Amazon will prompt you to do so. Later, you can use it to log into your instance.

Firewall security groups

If you haven't set up a firewall security group the wizard will create a new group that only allows port 22.

Note that to access the full range of services available on your appliance instance you'll later have to add additional ports to the security group.

Finalize and launch

Opening additional ports

Go to the security groups panel.

Here you may want to open any of the following ports:

443 SSL
12320 Web shell
12321 Webmin
12322 Database front-end

Accessing a running instance

Go to instances panel. Clicking on the instance shows its public IP address

"Instance actions -> Connect" shows how you can use the keypair to login with SSH.

You can also log in with the initial root password, which is available in the output of the system log (Instance Actions -> System Log). It's generated randomly so you may want to change it to something more rememrable if you're going to be using webmin or the Ajax web shell.

Note: Where applicable, the MySQL/root and PostgreSQL/postgres are also randomly set on first boot, and are identical to the root password displayed in the system log.


Setting up an EBS volume for data persistence

Go to "Volumes" panel

Create a volume. Make sure you create it in exactly the same availability zone as your instance otherwise you won't be able to attach it to the instance.

Attach it to your instance.

The new volume is "hotplugged" to your instance on the fly (it shows up as device /dev/sdf).

Mounting an EBS device

You don't need to do anything if the device has already been formatted (I.e., contains a filesystem). It will be mounted automatically by EBSmount when attached.

But new EBS devices need to be formatted first:

ebsmount-manual --format=ext3 /dev/sdf


JG's picture


I purchased your AMI and opened an AWS account today. On the last step of the AWS Request Instances Wizard, I get the error message "Subscription to ProductCode C1BC2EEF required". I cannot find that module in AWS online docs. Is that your AMI?

What should I do to complete the instantiation process?

JG's picture

 OK, C1BC2EEF is the product code for Turnkey's AMI. So the question is: where do I activate my subscription to your product?

Liraz Siri's picture

Did you maybe subscribe to one AMI and then try to create an instance for another one? If not, which AMI did you subscribe to?
JG's picture

I subscribed to "TurnKey Drupal6 AMI for Amazon EC2". When I click the link to the app on my Amazon purchase, I land on this page, which does not ask for a product key (even says a key is not needed - on top of this page!).

JG's picture

 My Amazon purchase states "TurnKey Drupal6 AMI for Amazon EC2", which is what I'm looking for, but maybe not the AMI stated in the tutorial above?

JG's picture

OK, my problem was that I needed to select the Drupal AMI, not the LAMP AMI which was given as example. duh.

Thanks for the help! 

Joey Gartin's picture

 I subscribed to the turnkey-joomla product and when I follow the instructions I cannot continue b/c of the subject error above.  I subscribed to the Joomla product and I am choosing the Joomla product in the AMI choices.

Does it take a certain time period (24 hours, etc) before the Product is registered?  I have confirmation of payment in AWS and they have given me a code, but I see no place to enter it in the instructions.

Thank you!

Liraz Siri's picture

There is no registration period. Once you are subscribed you should be able to use that AMI immediately. Are you absolutely sure you subscribed to the right appliance (e.g., Joomla) and that this is the same AMI you are selecting? Also which region are you using? If it doesn't work I'll try to setup an experiment and reproduce this error myself. Note that Amazon is reporting other successful subscriptions to the Joomla appliance so it's strange that it's failing on your end.

I apologize for the inconvenience on your end. The workflow is still a bit complex, and we are currently working on developing a web application that will make it easier to get up and running.

JG's picture

 At the end of first time formatting, mid-way through execution of the "/etc/init.d/ebsmount start" command, I get some errors in mysql-common:


(... everything OK until that point ...)
* Starting web server apache2                                           [ OK ]
executing: core
* Restarting OpenBSD Secure Shell server sshd                           [ OK ]

executing: drupal6

executing: mysql-common

shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory

chdir: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
chdir: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
 * Stopping MySQL database server mysqld                                 [ OK ]
mysqld_safe: no process killed
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
chdir: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
chdir: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
 * Starting MySQL database server mysqld                                 [ OK ]
 * Checking for corrupt, not cleanly closed and upgrade needing tables.
executing: php5
executing: phpmyadmin
executing: postfix
 * Stopping Postfix Mail Transport Agent postfix                         [ OK ]
 * Starting Postfix Mail Transport Agent postfix                         [ OK ]
                                                                         [ OK ]
Should I be concerned about the error messages?


Liraz Siri's picture

What these messages mean is that your current directory was probably moved by ebsmount into EBS while you were in it. Next time you might want to run ebsmount from the root directory. I don't think it matters anyhow.

Also, this isn't really the best place to discuss support issues. That's what the support forum is for.

Enquirer's picture

Hi guys

Thanks for the great walkthrough up above.   We're setting up a Postgres database and will probably use your solution

If it isn't easy to get the EC2 instances to automatically attach to the EBS volumes,  what do you recommend as far as operating a PostgreSQL database?      Should we shut it down when we know we aren't going to use it,  then go through the re-attach when we want to use it again?

Also is it possible to use the 150GB that comes with an intance as database storage?   Or is that unreliable/likely to disappear?

Also,  we're having some debate about which OS to use.   One teammate likes Fedora,  another wants OpenSUSE, etcetc.   Any words of wisdom on how you decided (incidentally, what do your images use?) and how well others work on EC2?



Neil Aggarwal's picture

I dont know about EC2, but the TKL images are based on Ubuntu 8.04 LTS.

Liraz Siri's picture

Though the official line at AWS is that you should plan for failure of your instance, and that's probably true at large scales, in practice it seems to be rare nowadays for an EC2 instance to fail. If you Google you'll find people with EC2 uptimes in excess of a year.

It is possible to use the instance storage for your database but please make sure to setup regular backups. Preferably automated. You should do that with any server, regardless of what platform it's running on. An EC2 server is no exception. Even if you use EBS!

BTW we're actually working right now on making all of that simpler. We want it to be easy for users to migrate instances running on local computers into the cloud, to setup regular backups, etc. If you register for an account on the site we'll let you know when we open that up for a public beta.

And Neil is right. All TurnKey images are currently based on the latest Ubuntu LTS (Long Term Support) version 8.04.3. Debian support is planned. Support for other distributions (e.g., CentOS) isn't currently planned but we're not opposed to it in principle, it's just a matter of resources.

Neil Aggarwal's picture

What would be involved in making CentOS based ports of the appliances?  I use CentOS for all my servers and am very familiar with it so I could lead that effort.

Liraz Siri's picture

  • First, we would need to upgrade our build Debian-based build infrastructure to support RPM packages...
  • Figure out what needs to be done to port over the custom packages we've developed (e.g., di-live, confconsole)
  • Create a CentOS based TurnKey Core
  • Port over all of the configurations and test them
  • Upgrade the web site to support CentOS based builds

In terms of the effort involved it's similar to migrating 40 different servers from Ubuntu Server to CentOS. Not a trivial effort, and currently a bit premature since there are a few prerequisites which we need to work on first. Volunteering to help does make it more likely we'll pursue that though.

In the meantime, let's move this and other non-EC2 related discussions to the forum.

Guest's picture

I cant seem to find your images on Amazon AWS. I put 'turnkey' into the filter box under 'All Images' within the 'Community AMIs' tab and nothing shows up. I even tried to enter a few ami ids (ami-xxxxxxx ) I see on your screenshots but nothing is showing up.... Are you still current on Amazon?

Alon Swartz's picture

I just checked and everything seems OK. My hunch is that you are connected to the new US-WEST-1 region, which does not yet contain that TurnKey images. The images are available in the other 2 regions US-EAST-1 and EU-WEST-1.

I hope this helps.
Guest's picture

Yep. I did connect to the US-WEST-1. I guess it doesn't really matter what region I use for now. Your response and work are much appreciated.

Merien's picture


Is it possible you convert the instances to EBS boot instances (or offer them as an alternative)? I have done one convert myself of my own custom instance and; although not very easy; if you dive into it; you should have it done within a few hours. EBS boot instance are far easier to backup (click of a button). If you need help / advice let me know; there are a few tricky things but if you get a good manual things shouldn't be too complicated.

Liraz Siri's picture

Thanks for the feedback! The way the images are set up it is currently not easy to use them with EBS boot. You're right about the importance of backup. It should be a one-click operation, and in fact we're working on making that happen...
Rodney Quillo's picture

This might help to convert the existing AMI  to EBS boot AMI


Dinis Cruz's picture

I just created an MediaWiki website at Amazon EC2 using this Turnkey's MediaWiki package  and for performance and resilience I would like to run the same MediaWiki content from two different EC2 locations (US and EU). 

(note: I've also just asked the same question at http://stackoverflow.com/questions/2265753/running-1-mediawiki-site-from...)

Alon Swartz's picture

I just updated the documentation to be inline with our latest release.

Notable changes:

  • Unified subscription: Global access to all TurnKey appliance AMIs in all regions. Previously you had to subscribe to each appliance separately which was unnecessarily complicated. (note that the free subscription is still available).
  • All regions: TurnKey AMI's are now available in all available regions (us-east-1,us-west-1,eu-west-1).
  • New buckets: The new AMI's are now stored in turnkeylinux-REGION (e.g., turnkeylinux-us-east-1)
  • EBSmount: New package that auto-mounts EBS devices when they are attached. This replaces the old ebsmount init script. The ebsmount-scripts-* have also been depreciated.
  • New kernel and ramdisk, including updated modules.
  • Advanced users will also be pleased to know that the new AMI's support user-data scripts (user-data that starts with #! will be executed during firstboot)
Pete Reilly's picture

I have successfully purchase all AMI's.  When I try to launch an instance, at the final step, I receive the following message:


Subscription to ProductCode C1BC2EEF required.

Alon Swartz's picture

You are attempting to launch the old LAMP appliance. All the newly released AMI's (2009.10-2) have the product code BA39B70F.

You can find the complete AMI's listing here, or if you are searching with the AWS console, take note of the new buckets naming convention:

  • turnkeylinux-us-east-1 (US - North Virginia)
  • turnkeylinux-us-west-1 (US - North California)
  • turnkeylinux-eu-west-1 (Europe - Ireland)