In this tutorial you will customize a RightScale server template to build your own LAMP server! This tutorial will help you understand the basics of our pre-built templates and assets, as well as explain how to fully take advantage of them by cloning and customizing our server templates. The key benefits are that the server templates get you up and running quickly, while also giving you the flexibility to clone and customize these templates so that you can reuse and leverage all the pre-existing assets. Why recreate the wheel?
The Intermediate Example can be completed with any type of account (Free Trial, Developer, Premium).
If you do not have a RightScale account, sign up for a Free Trial account at http://www.rightscale.com. If you are running a trial account and your EC2 time has expired, you will need to set up a Devloper account and use your own AWS credentials. See Sign up for AWS (AWS Credentials) and Add AWS credentials to RightScale.
If you are using a free trial account, you must activate your trial account by clicking on the link that was emailed to you from notifier@my.rightscale.com.
RightScale offers several server templates that are publicly available to all users. Since you cannot make changes to these public server templates directly, you'll first have to clone it and then customize it accordingly. But, these public server templates are an excellent way to get a head start instead of trying to build your own server template from scratch.
In this example we will customize the LAMP server template to launch a LAMP server on EC2.
Go to Design -> Servers -> Server Templates.
Click on the RightScale tab. You will see list of public/premium server templates that are maintained by RightScale that you can clone and customize for your own deployment. For this example, click on the LAMP V3 server template.

Click the Clone button. This will make a copy of the server template so that you can make changes to it.

Now rename the cloned LAMP server template. Simply click on the name and type a new name, "LAMP (clone)" and click OK.

Go to Design -> Servers -> Server Templates. Under the Private tab you should now see the cloned LAMP server template. When you make a clone of a server template, it gets added to your Private tab. Cloned templates are automatically generated with incrementing version numbers. Therefore, even if you clone a v4 server template, it will appear as v1 when you clone it. Once you have successfully cloned the server template, you're ready to start customizing it. But first, let's see what's already inside the LAMP server template.
Click on LAMP (clone) under the Private tab.

Then click on the Scripts tab.

Notice the list of boot, operational, and decomission scripts. The default version of this server template is designed to load an application and a MySQL dump that are already stored on Amazon S3. But, to reduce this dependency on S3, we are going to remove these scripts and replace them with new RightScripts that get a database and application that we've already uploaded for you.
NOTE: For a list of all the RightScripts and their descriptions see RightScripts.
Now we can customize the cloned server template to satisfy our needs by adding, removing, and rearranging RightScripts.
Let's modify the server template so that we can specify the URL of a specific web application and a MySQL dump file that we want to load.
We'll need to create two new RightScripts that do the following:
- Gets a MySQL database from a URL and applies it to the server template
- Gets a PHP web application from a URL and applies it to the server template
Go to Design -> Servers -> RightScripts.
Click the New button to create a new RightScript. Name it get and apply phptest db and paste the following code into it. This RightScript will download and apply the MySQL dump that is pointed to by the variable DUMP_GZIP_URL. We've already uploaded a db and app 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 Save.
Click on RightScripts and click New to create another RightScript.
Name the new RightScript, get and apply phptest app and paste the following code into it:
#!/bin/bash -e ## Check if optional application root is specified if [ -z "$OPT_WWW_DOCUMENT_ROOT" ]; then content_dir="/home/webapps/$APPLICATION/current" else content_dir=$OPT_WWW_DOCUMENT_ROOT fi 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:

Click Save.
Now we need to add the new RightScripts to the cloned server template and then remove/reorder some of the other RightScripts.
Go to Design -> Servers -> Server Templates.
Click LAMP (clone). Click the Scripts tab.
First we want to replace some of the default scripts.
Remove the DB MySQL s3 mysqldump import v1 script by clicking the remove button.

Now add the new RightScripts that we just created: get and apply phptest db and get and apply phptest app.
Select them from the private RightScript pulldown menu and add them as boot scripts.

To change the order of the RightScripts, simply drag and drop a RightScript into the desired position.

Now remove the following RightScripts:
The final version should look like this:

To access the database, we 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 -> Servers -> Credentials. Click New Credential.

Name the first credential, DBAPPLICATION_PASSWORD (not case-sensitive) and enter app_password for the value (you can leave the description blank) and click Save.
Create a second record named, DBAPPLICATION_USER and enter app_user for the value and click Save.
You now have two credentials that will be used in order to access the database.

Now we are ready to configure the input parameters.
Go to Design -> Servers -> Server Templates. Under the Private tab, click on the nickname of the "LAMP (clone)" server template. Click on the Inputs tab and click Edit.

Enter the following inputs:
| APPLICATION | Text | phptest |
| APP_TAR_URL | Text | http://s3.amazonaws.com/rightscale_tutorials/phptestapp.tgz |
| DBAPPLICATION_PASSWORD | Cred | DBAPPLICATION_PASSWORD |
| DBAPPLICATION_USER | Cred | DBAPPLICATION_USER |
| DB_SCHEMA_NAME | Text | phptestdb |
| DUMP_GZIP_URL | Text | http://s3.amazonaws.com/rightscale_tutorials/phptest.sql.gz |
| WEBSITE_DNS | Env | EC2_PUBLIC_HOSTNAME |
The list of inputs should now look like the following screenshot.

If everything looks great, click Save.
After you have entered all of the necessary input parameters, you are now ready to launch the server.
Click the Launch button.

Troubleshooting
If you receive an error message saying that your account has insufficient funding to perform this action, you need to verify your email address. Go to your email account and check for an email confirmation from notifier@my.rightscale.com. It may be in your bulk/spam folder. Click on the email link and your account should be activated. Refresh and launch the server again. If you are still experience problems, please contact support@rightscale.com.
Verify your settings and click Launch.

To track its progress, go to the Dashboard home page (click on the RightScale logo). In about 5 minutes you will have a fully functioning LAMP server running on EC2! Once your server is fully operational, you can preview your new LAMP server in a browser window. Click on the (Public) DNS name (ex: ec2-75-101-208-94.compute-1.amazonaws.com).

You should now see the default PHP page. You should also receive an email from notifier@my.rightscale.com informing you that the 'LAMP' instance is now operational.

Congratulations! You just learned how easy it is to launch a LAMP server on EC2 with the RightScale Dashboard. You didn't have to mess with any hardware, install any OS or software programs because the server templates automatically completed all of these tasks for you when you clicked the Launch button. Server templates 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. Go to Manage -> Servers -> Active Servers. Click the shutdown button.

----------------------
Did you find this document helpful? Please feel free to leave us a comment below. We're always looking for ways to improve our documentation. Thanks!
I think that we also need the URL to the database dump for the $DUMP_GZIP_URL in order to run the 'get and apply phptest db' RightScript. edited 01:46, 29 Apr 2008
As for the URL, whoops, my mistake. I added a link :)