Note: Please go to to access the current RightScale documentation set. Also, feel free to Chat with us!
Home > Clouds > AWS > Tutorials > Beginner Examples > Intermediate Example

Intermediate Example


For best results, use Firefox, IE8+ or Chrome. The Dashboard no longer supports IE6-7.


This tutorial will help you understand the basics of our pre-built ServerTemplates and other assets. It will also explain how to take full advantage of these benefits by cloning and customizing RightScale ServerTemplates. The key benefits are that ServerTemplates help you get up and running quickly, while also giving you the flexibility to clone and customize them so that you can reuse and leverage all the pre-existing assets. There is no reason to "reinvent the wheel" so to speak.


Clone and rename the LAMP ServerTemplate

RightScale offers several ServerTemplates that are publicly available to all users. Since you cannot make changes to these public ServerTemplates directly, you'll first have to import the ServerTemplate locally to your Rightscale account, then clone it and customize it accordingly. These public ServerTemplates are an excellent way to get a head start instead of trying to build your own ServerTemplate from scratch.

In this example we will customize one of the LAMP ServerTemplates to launch a basic LAMP server on Amazon's EC2. 

  • Go to Design > MultiCloud Marketplace > ServerTemplates
  • A library of ServerTemplates is shown that you can clone and customize for your own purposes. 
  • For this example, use the Search feature to find the most recent LAMP All-In-one with MySQL 5.0 - 11H1.1 ServerTemplate. 
  • Select the ServerTemplate and import it. This will place a static, read-only copy of the ServerTemplate in your 'local' account view.

Note: ServerTemplates are cloud-agnostic. You can use the same ServerTemplate to launch instances into multiple clouds or AWS regions. In this tutorial, you will launch an instance in the AWS US-East region. 

  • Click the Clone action button. This will create an editable read/write copy of the ServerTemplate in your 'local' account view. Cloned ServerTemplates are automatically generated with incrementing version numbers. Therefore, even if you clone the ServerTemplate, it will append a version number to the end (e.g., LAMP All-In-One with MySQL 5.0 - 11H1.1 v1) when you clone it. Once you have successfully cloned the ServerTemplate, you are ready to start customizing it.
  • Rename the cloned LAMP ServerTemplate if you wish. Simply click on the ServerTemplates nickname towards the top of the page and type a new name, such as "LAMP All-In-One with MySQL 5.0 - 11H1.1 (clone)" and click OK.

Let's take a closer look at what's already inside the LAMP ServerTemplate. 

  • Click on the cloned ServerTemplate's Scripts tab. 


Notice the list of boot, operational, and decommission scripts. The default version of the ServerTemplate is designed to load an application and a MySQL dump from an S3 bucket. You can also retrieve the file from another location by specifying a URL by using a different type of script, which we will create later on in this tutorial. In this tutorial you are going to change how the web server is going to retrieve its database dump file and application code by replacing a couple of the boot scripts with Rightscripts that you're going to create.

Create new RightScripts

Now you can customize the cloned ServerTemplate to satisfy our needs by adding, removing, and rearranging RightScripts.

We will be modifying the ServerTemplate so that you can specify the URL of a specific web application and a MySQL dump file that you want to load. 

You'll need to create two new RightScripts that do the following:

  • Gets a MySQL database from a URL and applies it to the ServerTemplate
  • Gets a PHP web application from a URL and applies it to the ServerTemplate
Create a RightScript for getting a MySQL database from a URL
  • Go to Design > RightScripts
  • Click the New action button to create a new RightScript. Name it "get and apply phptest db" and paste the code below into the Rightscript editor. This RightScript will download and apply the MySQL dump that is pointed at by the input variable DUMP_GZIP_URL. We have already uploaded a database and application to S3 that you can use for this tutorial. Links for these files will be provided later in this tutorial when we configure the Inputs. 
#!/bin/bash -e
cd /tmp
wget $DUMP_GZIP_URL -O dump
gunzip -c dump | mysql



Click the Save action button when ready.

Create a RightScript for getting a PHP App from a URL
  • From the Design > RightScriptsmenu, click on the New action button again to create another RightScript. Name the new RightScript "get and apply phptest app" and paste the following code into the Rightscript editor:
#!/bin/bash -e 

## Check if optional application root is specified
if [ -z "$OPT_WWW_DOCUMENT_ROOT" ]; then

mkdir -p $content_dir
cd /tmp

#get application tarball from S3
wget $APP_TAR_URL -O app

#install applicaton
tar -xzf app -C $content_dir

The script above does the following:

  • Sets the variable content_dir to the value of the OPT_WWW_DOCUMENT_ROOT Input if it is specified, or to /home/webapps/$APPLICATION/current if it is not specified.
  • Downloads and installs the tarball pointed at by the APP_TAR_URL Input to this directory.


Click the Save action button when ready.

Remove old and add new RightScripts

Now you need to add the new RightScripts to the cloned ServerTemplate and then remove/reorder some of the other RightScripts.

  • Go to Design > ServerTemplates
  • Locate and click on your cloned LAMP ServerTemplate that we created earlier
  • Click the Scripts tab

First we want to add the new RightScripts that we just created: "get and apply phptest db" and "get and apply phptest app." 

  • Click the Add Script action button in the Boot Script section. You are presented with an Add Script dialog box.
  • For the Publisher, click on "Unpublished." The two Rightscripts we created are only local, unpublished scripts and have not been shared/published by yourself or anyone else.
  • Locate and click on one of the two new RightScripts that we created above in the Search Results pane.
  • Click the Select action button when ready.

Select the Add Script action button again and repeat the process for the second RightScript.

Rearrange the RightScripts execution order

To rearrange the order of RightScripts, use the up/down arrow icon icon_MoveScript-v1.gifnext to the boot RightScript of choice and simply drag and drop it into place. 

  • Place get and apply phptest db after the script DB MySQL 5.0 server install - 11H1
  • Place get and apply phptest app after the script WEB PHP install - 11H1

Since we are performing the same actions as two existing scripts on this template, we also want to remove the following two RightScripts:

  • DB MySQL s3 mysqldump import (boot script)
  • WEB Application s3 code checkout (boot script)


Add RightScale Credentials

To access the database, you will need to grant access to a user. Instead of entering a username/password in plain text, RightScale has developed a Credential store to safely hold your passwords. Let's create two credentials for the DB username and password. The "Value" field is where you enter your username or password.

  • Go to Design > Credentials
  • Click on the New Credential action button.
  • Name the first credential DBAPPLICATION_PASSWORD (not case-sensitive) and enter app_password for the value.
  • Although not mandatory, its considered best practice to fill out a helpful Description in the "Description" field.
  • Click the Save action button when ready

Repeat the process, but this time create a second credential named DBAPPLICATION_USER and enter app_user for the value.

You now have two credentials that will be used in order to access the database.


Create an S3 Bucket for Storing Database Backups

The ServerTemplate is designed to create regular backups of the database and save them as gzip files to an S3 bucket that you specify using the DB_MYSQLDUMP_BUCKET input. To create an S3 bucket, go to Clouds > AWS Global > S3 Browser and click on the New Bucket action button, then provide a Bucket Name and Location e.g., 'myname-db'

Configure the Input parameters

Now we are ready to configure the Input parameters.

  • Go to Design > ServerTemplates
  • Click on the "Nickname" link of your imported and cloned ServerTemplate e.g., "LAMP All-In-One with MySQL 5.0 (clone)"
  • Click on the ServerTemplate's Inputs tab and click Edit

Now you will define values for these Inputs at the ServerTemplate level. By defining these values at the ServerTemplate level, any servers that are created with this version of the ServerTemplate will inherit these values.

Fortunately, a lot of the Inputs have already been set, but since you just added two new RightScripts, there are a couple of Inputs that need to be set with the correct value.

Note: You may see a warning message in red if an input value has an extra space either before or after the entered value. This extra whitespace could cause errors. As a best practice, you should always remove any leading/trailing whitespaces in any Input values. Warning! Input contains leading/trailing whitespace.

Edit the following inputs accordingly:

Input Name Input Type Value
 APPLICATION Text Provide an arbitrary name for your application. (e.g. myapp)


However, you could use this script to similarly pull the application code from another location on the web. e.g.,



Or if you don't want to use the Credential you could also use:


Text: app_password



Or if you don't want to use the Credential you could also use:


Text: app_user

 DB_MYSQLDUMP_BUCKET  Text This ServerTemplate is currently designed to save continuous backups of the database to an S3 bucket. Provide the name of an S3 bucket to store backups in e.g., mybucket-db.

Defines the prefix that will be used to name the backups of the database e.g., mydb

Backups of the database will be saved to the specified S3 bucket specified in the DB_MYSQLDUMP_BUCKET Input. The prefix will be used to name the backup file accordingly e.g., mydb-timestamp.gz


Provide the following database schema name:


text: world



However, you could use this script to similarly pull the application code from another location on the web. (e.g.


If you set up DNS A Records for this instance, you could specify a fully qualified hostname, but since this is only a test, set it to an EC2 environment variable for public hostname, like so:





If everything looks accurate, click the Save button.

Create the Server

Now that you have customized your ServerTemplate and defined its default input parameters, it is time to create a server. In RightScale, you create a server from a ServerTemplate so that it can inherit a majority of its core configurations from the template. You cannot create a server from scratch. Since we just finished customizing our ServerTemplate we are now ready to add (create) a server to a deployment. When you create a server, you must specify into which deployment the server will be added. A server cannot exist outside the context of a deployment. Click the Add Server button when viewing the ServerTemplate's Info tab. Since this tutorial is for demo purposes, you can just add it to the "Default" deployment if you wish. When adding/creating the server:

  • First you will need to choose which AWS region you wish to launch a server into. Select "AWS US-East" from the cloud dropdown.
  • Select either the "Default" deployment in the "Deployment" dropdown, or choose one of your own.
  • Click the Continue button
  • You will be prompted with the Add Server Assistant dialogue. From here, you can fill in the Nickname, SSH key and other pieces of information required by the server for it's creation.

Launch the Web Server on EC2

After you have added a server to a deployment, you are ready to launch the server.

  • Click the Launch action button towards the top of the server's Info tab

Next, you may see a list of Input values for the server you are about to launch (depending if you have 'verify inputs' enabled). This screen gives you one last chance to change any of the Input parameters before launching the server. If there are any missing fields that are required, they will be highlighted in red. If you change/set a value at this point in the launch process, the changes will only take affect on this particular instance; it will not change the values set at the ServerTemplate level.

  • Verify your settings and click the Launch action button when ready.

To track its progress, follow the Events window on the left of the page. You should see a progression from "pending" to "booting" and eventually "operational." In about five minutes you will have a fully functioning LAMP server running on EC2! 


Troubleshooting using Audit Entries

The new instance will appear under the Default Deployment (unless you specified another deployment when adding the server from the template). To check progress in a more detailed fashion:

  • Navigate to the Manage > Servers > Active tab
  • Select your server e.g., "LAMP All-In-One with MySQL 5.0 (clone)" 
  • Select the Audit Entries tab
  • Depending on your current progress, you will see something similar to this:


In our example, you can see the server's status progress under the "Summary" column of the table. Select a link under Summary to view helpful troubleshooting information. For example, if your server did not progress from pending to booting to operational, the last link could be "stranded" (not operational), indicating a script failure or similar. Look at the audit entry prior to "stranded" (e.g., "boot failed: SYS Timezone set -11H1....") to view in-depth information that can help you troubleshoot the problem. You will see the boot scripts starting, logging information and more. Warnings and errors can also be displayed in the audit entries, which provide a starting point for troubleshooting and resolving issues.

Once your server is fully operational, you can preview your new LAMP server in a browser window. 

  • Click the server's Info tab
  • Click on the "Public DNS Name" link: (e.g.,


You should now see index page for our test PHP application. You should also receive an email from informing you that the 'LAMP' instance is now operational:



Congratulations! You just learned how easy it is to launch a customized LAMP server on EC2 with the RightScale Dashboard. The best part about launching servers on the cloud is that you no longer have to mess with any hardware, install any OS or software programs, because the ServerTemplates will automatically complete all of these tasks for you when you launch them. ServerTemplates make it easy to launch instances on EC2 while also giving you the control and flexibility to customize each server accordingly.

Don't forget to terminate your instance when you're done to avoid any unwanted usage fees. Termination can be completed from the Manage > Servers page from the "Actions" column on the right side of the page, or alternatively by directly navigating to the Server > Info tab of your server and clicking the Terminate button.

You must to post a comment.
Last modified
13:20, 16 Jul 2013



This page has no classifications.



© 2006-2014 RightScale, Inc. All rights reserved.
RightScale is a registered trademark of RightScale, Inc. All other products and services may be trademarks or servicemarks of their respective owners.