In this tutorial you will customize a RightScale ServerTemplate to build your own LAMP (Linux Apache MySQL and PHP/Perl/Python or other Programming language) server! This tutorial will help you understand the basics of our pre-built templates and assets. It will also explain how to take full advantage of these benefits advantage by cloning and customizing RightScale ServerTemplates. The key benefits are that the ServerTemplate 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. There is no reason to recreate the wheel so to speak.
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, and you are not ready to sign-up for one of our pay editions, you can create an AWS account and set up a Free Developer account. See Upgrade Your Account to learn how to sign-up for AWS and add your credentials into the Dashboard.
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 ServerTemplates that are publicly available to all users. Since you cannot make changes to these public ServerTemplates directly, you'll first have to clone it and then customize it accordingly. But, 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 the LAMP ServerTemplate to launch a basic LAMP server on Amazon's EC2.
Go to Design -> ServerTemplates.
Click on the RightScale tab. You will see list of public/premium ServerTemplates that are maintained by RightScale that you can clone and customize for your own deployment. For this example, click on the most recent LAMP ServerTemplate.
NOTE: For multi-cloud support, you may notice buttons that are labeled slightly different, including the cloud name. For example, "New EC2," "New Flexiscale," etc.

Click the Clone button. This will save a copy of the ServerTemplate to your Private tab so that you can make changes to it.

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

Go to Design -> ServerTemplates. Under the Private tab you should now see the cloned LAMP ServerTemplate. Cloned templates are automatically generated with incrementing version numbers. Therefore, even if you clone a v4 ServerTemplate, it will appear as v1 when you clone it. Once you have successfully cloned the ServerTemplate, you're ready to start customizing it. But first, let's see what's already inside the LAMP ServerTemplate.
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 ServerTemplate 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 List of RightScripts.
Now you can customize the cloned ServerTemplate to satisfy our needs by adding, removing, and rearranging RightScripts.
Modify 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
Go to Design -> 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 ServerTemplate and then remove/reorder some of the other RightScripts.
Go to Design -> ServerTemplates.
Click LAMP (clone). 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.
Select them from the private RightScript pulldown menu and add them as boot scripts.

After selecting the "Add" button, the RightScale Dashboard header displays "RightScript was successfully added" and the Boot Scripts displays them as "[HEAD]" versions.
To rearrange the order of RightScripts, use the up/down arrow icon next the the RightScript and simply drag and drop it into place.
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 -> 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. The RightScale Dashboard header displays "Credential was successfully created."
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 -> ServerTemplates. Under the Private tab, click on the nickname of the "LAMP (clone)" ServerTemplate. Click on the Inputs tab and click Edit.

Edit the following inputs accordingly:
| 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. When you click the email validation link 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). Depending on how often you check its status, you should see a progression from "pending" to "booting" and eventually "operational." In about 5 minutes you will have a fully functioning LAMP server running on EC2!
To check progress in a more detailed fashion, navigate to Manage > Servers and select your "Lamp (clone)" server under the Active tab. Select the Audit Entries tab. Depending on your current progress, you will see something like this:

In our example, you can see the server instance status progression 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). Look at the "stranded" audit entry to view in-depth information that can help you troubleshoot the problem. You will see the boot scripts starting, logging information, etc. Warning and errors can also be displayed in the audit entries, which provides a starting point for resolving the issue.
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-72-44-38-255.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. 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 click the Launch button. 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. Go to Manage -> Servers and 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 :)
I see that the methods for obtaining the files from S3 are different ('sc3cmd get' and 'wget'). Is there a reason to use one over the other?
Thanks!
Mary
Yes, that is worded a little confusing. Let me see if I can clarify...
The scripts are originally designed to fetch objects in a private bucket in you S3 account. This requires populating your bucket with the necessary objects, and authenticating with S3 for the transfer. We chose to take this part out to reduce the complexity and also to permit trial users to use this tutorial.
Since the objects are hosted in a public S3 bucket, they are addressable with http and using wget for this is very simple. You certainly could use s3cmd instead, but it is more complex.
hope this helps,
Martin