Deploying your Pressflow application to a Pantheon AMI

This article describes how to deploy your Pressflow application from WebEnabled to a Pantheon AMI (Amazon Machine Image). The first step is to instantiate a Pantheon AMI. Then you need to use your Dashboard at WebEnabled to deploy your Pressflow application to it.

Procedure for creating a fresh Pantheon instance

Before getting started you may also want to watch the video at that shows how to create a Pantheon AMI instance.

  1. First, we need to get the image id of the newest Pantheon Mercury image (they are updated frequently):
    $ ec2-describe-images -x all | grep mercury
    IMAGE ami-b431d3dd chapter3-storage/PANTHEON-pressflow-mercury32-0.81-Beta.manifest.xml 904568547828 available public i386 machine aki-6eaa4907 ari-42b95a2b
    IMAGE ami-bc31d3d5 chapter3-storage/PANTHEON-pressflow-mercury64-0.81-Beta.manifest.xml 904568547828 available public x86_64 machine aki-a3d737ca ari-7cb95a15

    PANTHEON-pressflow-mercury32 (i386) is the image we need, and its ID is ami-b431d3dd.

  2. Let's create a new instance of the image with this ID:
    $ ec2-run-instances ami-b431d3dd -k gsg-keypair2
    RESERVATION r-3a0a9752 938479617006 default
    INSTANCE i-e463658c ami-b431d3dd pending gsg-keypair2 0 m1.small 2010-01-23T18:37:44+0000 us-east-1a aki-6eaa4907 ari-42b95a2b

    Here, gsg-keypair2 is the id of a ssh key pair that you configure with your Amazon account.

  3. Now, let's find out which instances were are running:
    $ ec2-describe-instances
    RESERVATION r-3a0a9752 938479617006 default
    INSTANCE i-e463658c ami-b431d3dd domU-12-31-39-07-CC-B4.compute-1.internal running gsg-keypair2 0 m1.small 2010-01-23T18:37:44+0000 us-east-1a aki-6eaa4907 ari-42b95a2b

    The second instance with the image id ami-b431d3dd and hostname The instance id to be used for managing this instance is i-e463658c.

    NOTE: if you run ec2-describe-instances right after creating an instance, you will see 'pending' instead of the hostname. You may need to wait for several minutes.

  4. Once the instance is created and its hostname known, you can access it via ssh from your desktop using the private key:
    jeffcd@localhost:~$ ssh -i pantheon.ssh.key

    NOTE: the new instance also becomes available via HTTP and the default Pressflow instance has no password set, so anyone who accesses this instance first can become a Pressflow admin.

  5. When we no longer need the instance, we destroy it using the instance id we seen previously in the output of the ec2-describe-instances command:
    $ ec2-terminate-instances i-e463658c
    INSTANCE i-e463658c running shutting-down

    Upon termination, the instance is still reported by ec2-describe-instances for some time (approximately one hour):

    $ ec2-describe-instances
    RESERVATION r-3a0a9752 938479617006 default
    INSTANCE i-e463658c ami-b431d3dd terminated gsg-keypair2 0 m1.small 2010-01-23T18:37:44+0000 us-east-1a aki-6eaa4907 ari-42b95a2b

    Note the 'terminated' label instead of the hostname. At this point you still need the instance if you plan to deploy to it so don't terminate it just yet.

Prepare your Pantheon AMI instance for deployment

After creating a new Pantheon instance as described in the previous section, the following steps should be taken in order to prepare the newly created instance for deployment using WebEnalbed:

  1. Login as root to the newly created instance via using the ssh key
    jeffcd@localhost:~$ ssh -i pantheon.ssh.key
  2. Set a password for the www-data user:
    # passwd www-data
  3. Make /var/www (which is supposed to host exactly one webenabled site) writable to www-data:
    # chown -R www-data: /var/www
  4. Precreate a mysql database:
    # mysql -u root -e 'create database webenabled;'
  5. Allow password authentication for ssh:

    Edit /etc/ssh/sshd_config changing 'PasswordAuthentication no' to 'PasswordAuthentication yes':

    # vi /etc/ssh/sshd_config

    Reload ssh config:

    # /etc/init.d/ssh reload

Deploy your Pressflow application from WebEnabled to the Pantheon AMI instance

Now that your Pantheon AMI is ready you can deploy your Pressflow application.

1. Login to your Dashboard and find the project where the Pressflow instance resides

Once you find the project click the "Servers" link.

2. Add a new external server

Click on the "Add new external server" button.

3. Fill in the host details

The host is displayed in the previous section. It is unique to each AMI instance.

4. Fill in the MySQL information

Once completed click the "Save" button.

5. Confirmation of new external server

Once saved successfully you will see a confirmation message and the server will be saved for deployment on-demand.

6. Browse back to your Dashboard homepage

Select the application you want to deploy. Then select the server in the dropdown under the Deploy column.

7. Deploy the application to the AMI

Make sure that you select to deploy the database. Then click the "Deploy" button. You will need to wait up to 5 minutes for the deployment to complete. Be patient and do not close the browser or go to another page while deployment is in progress.

8. Once complete you will get a message with your new admin password