Table of Contents
This tutorial introduces how to set up, configure, and launch a fully functioning LAMP (Linux Apache MySQL and PHP/Perl/Python or other Programming language) server running on Rackspace Open Cloud using a RightScale ServerTemplate. This tutorial is useful for a developer who wants to host a LAMP server on Rackspace Open Cloud.
ServerTemplates consist of a base image that contain a lightweight Linux installation (in our example shown below, CentOS ). In this tutorial you will use one of our LAMP all-in-one ServerTemplates to launch a fully functioning LAMP server. With this configuration, the entire LAMP stack runs on a single cloud server.
First, you must create a tarball of your PHP application code and a properly formatted gzipped dump of your MySQL database.
NOTE: The MySQL dump filename must follow the specified format: 'prefix-timestamp.gz' Ex: myapp_prod_dump-20080416234.gz, where 'myapp_prod_dump' is the prefix. The PHP application code must have the .tgz extension, for example 'myapp.tgz'
If you would like to use sample files to complete this tutorial, listed are a sample PHP file and MySQL dump file.
Alternatively, our services team provides the source files for another test application (further known as the 'world' application). The database dump file comes directly from the 'world' test database provided by MySQL as well. The link below for the application code will download a .tgz tarball file for you, so there is no need to create one in a separate step.
Fill in your username, password, and schema name and execute these commands. A dump will be created in your /tmp directory. In the code below, you may replace 'myapp_prod_dump' with your own prefix.
USER= PASSWD= SCHEMA= suffix=`date "+%Y%m%d%H%M"` mysqldump --single-transaction -u $USER -p$PASSWD $SCHEMA | gzip -c > /tmp/myapp_prod_dump-$suffix.gz
Change to the root directory of your application and execute the following command:
tar czf /tmp/myapp.tgz .
Now that you have a dump of your database and a tarball of your application, you can upload those files to a Rackspace Cloud Files container. Use two different containers: one for your application and one for your database backups to isolate your application from the many database backups that will occur. (This ServerTemplate is designed to take regular backups of your database and save them to your designated Cloud Files container.)
Your application and database files are now stored in Rackspace's cloud storage for retrieval when the server launches.
Go to Manage > Deployments and click the New button. Give the deployment a nickname (e.g., Rackspace), then click Save.
The next step is to use the imported ServerTemplate to add a server to the new deployment.
View your newly imported ServerTemplate by navigating to Design > ServerTemplates > Your ServerTemplate.
While viewing the ServerTemplate, click Add Server.
Select 'Rackspace Open Cloud' as your cloud and the deployment you created earlier, then click Continue.
Next, provide some basic configuration settings about your server in the Add Server assistant:
For more information on adding a server, see Add Server Assistant.
The MultiCloud Image will automatically select the appropriate base machine image for you based on the selected cloud infrastructure.
The ServerTemplate is pre-defined to use some commonly used credentials. Create the following credentials by going to Design > Credentials and selecting the New button:
The next step is to customize the server by providing values for any missing inputs. Define any missing inputs at the deployment level to take advantage of the input hierarchy rules that apply (see Inheritance of Inputs for more details.) A server will inherit its input configurations first from the ServerTemplate and then from the deployment.
Input Name | Description | Input Type | Example Value |
Database Schema Name | Enter the name of the database schema to which applications will connect to. The database schema should have been created when the initial database was first set up. This input will be used to set the application server's database configuration file so that applications can connect to the correct schema within the database. This input is also used for database dump backups in order to determine which schema will be backed up. | Text | text: mydbschema
For the example "world" database listed above, use:
text: world |
Input Name | Description | Input Type | Example Value |
Dump Container | The cloud storage location where the dump file will be saved to or restored from. For Rackspace Cloud Files, use the container name. | Text | text: <your cloud files DB container> |
Database Schema Name | Enter the name of the database name/schema to create/restore a dump from/for. | Text | text: mydbschema
For the sample "world" database provided above, use:
text: world |
Dump Prefix | The prefix that will be used to name/locate the backup of a particular database dump. Defines the prefix of the dump file name that will be used to name the backup database dump file, along with a timestamp. If you are using our sample myapp_prod_dump-200804161345.gz dump file, specify 'myapp_prod_dump' as the prefix value. | Text | text: myapp_prod_dump
For the sample "world" database listed above, use:
text: world |
Dump Storage Account ID | In order to write the dump file to the specified cloud storage location, you need to provide cloud authentication credentials. For Rackspace Cloud Files, use your Rackspace login username (e.g., cred:RACKSPACE_OPEN_CLOUD_USERNAME). | Cred | cred: RACKSPACE_OPEN_CLOUD_USERNAME |
Dump Storage Account Provider | Location where the dump file will be saved. Used by dump recipes to back up to remote object storage (Cloud Files). | Text | cloudfiles |
Dump Storage Account Secret | In order to write the dump file to the specified cloud storage location, you will need to provide cloud authentication credentials. For Rackspace Cloud Files, use your Rackspace account API key (e.g., cred:RACKSPACE_OPEN_CLOUD_AUTH_KEY). | Cred | cred: RACKSPACE_OPEN_CLOUD_AUTH_KEY |
Input Name | Description | Input Type | Example Value |
Account Name | The account name (i.e. username, ID) that is required to access files in the specified location. This input is optional and may not be required. | Cred | cred: RACKSPACE_OPEN_CLOUD_USERNAME |
Account Credential | A valid credential (i.e. password, SSH key, account secret) to access files in the specified location. This input is always required for Git and Rsync but may be optional for other providers. | Cred | cred: RACKSPACE_OPEN_CLOUD_AUTH_KEY |
Repository Provider | Specify where the application code should be checked out from. | Text | repo_ros |
Repository URL/ROS Container | The URL that points to the location of the repository that contains the application code. Or the name of the ROS container where a tarball of the application code will be retrieved from if you use 'repo_ros' provider. | Text | text: <your app cloud files container> |
ROS Prefix | The prefix that will be used to locate the correct tarball of the application. For example, if you're using the sample 'myapp2.tgz' specify 'myapp2' as the ROS Prefix. | Text | text: myapp2
For the sample "world" application listed above, use:
text: world |
ROS Storage Account Provider | The Remote Object Storage (ROS) service where the tarball of the application code will be retrieved from. | Text | cloudfiles |
Click the server's Launch button.
Next, you may see an Input Confirmation screen before the server is launched. Since you earlier defined values for any missing inputs, none of the inputs are highlighted in red. Click the Launch button again.
Soon you will have a fully operational cloud instance running your own PHP application.
Once operational, you can view your PHP application in a browser window.
You should see a PHP information screen in your browser window.
You can also click on the server's Monitoring tab to view real-time monitoring graphs.
Do not forget to terminate your server to avoid unwanted usage fees. Click the server's Terminate button to terminate the server if desired.
© 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.