In this learning activity, we will implement a LAMP stack on a single Lightsail instance and then migrate it to a scalable full-tier architecture.
The goal of the learning activity is to gain experience with:
* Creating a LAMP Lightsail instance
* Creating a Lightsail managed database instance using MySQL
* Reconfiguring a LAMP application to use the Lightsail managed database
* Cloning a front-end application server
* Scaling an application front end
* Adding a load balancer to distribute incoming load
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Create the managed database, load balancer, and LAMP instance.
Create a LAMP Instance
- Make sure the region is set to
us-east-1
. - Select the LAMP (PHP 5) blueprint.
- Select the 2 GB instance plan.
- Name the instance
PHP-fe-1
.
Create a Lightsail Database Instance
- Ensure the region is set to
us-east-1
. - Pick the default MySQL version.
- Check the box next to Specify Login Credentials and enter your credentials. Use the password
taskstasks
. - Select the High Availability plan.
- Select the 2 GB instance size.
- Name the database
todo-db
.
Create a Lightsail Load Balancer
- Ensure the region is set to
us-east-1
. - Name the load balancer
todo-lb
.
- Make sure the region is set to
- Configure and deploy the application on a single instance.
- Log in to the
PHP-fe-1
instance using SSH. - Follow the steps listed at https://github.com/linuxacademy/aws-lightsail-deep-dive/blob/master/Scenario3/learning_activity_3/1_fe_monolith_commands.sh.
- Complete the application installation at http://INSTANCEIP/install.php.
- Verify that the application is functional at http://INSTANCEIP.
- Create the task
remember to buy a cat
.
- Log in to the
- Migrate the application to the managed database instance.
- Log in to the
PHP-fe-1
instance.- Complete the database migration steps up to and including line 24 at: https://github.com/linuxacademy/aws-lightsail-deep-dive/blob/master/Scenario3/learning_activity_3/2_migrate_to_managed_db.sh
- Create the database tables on the managed database instance using http://INSTANCEIP/install.php.
- Verify the application’s functionality at http://INSTANCEIP.
- Complete the database migration steps from line 28 onwards at https://github.com/linuxacademy/aws-lightsail-deep-dive/blob/master/Scenario3/learning_activity_3/2_migrate_to_managed_db.sh
- Verify the application at http://INSTANCEIP. You should see the
remember to buy a cat
task.
- Log in to the
- Scale and load balance the front-end tier.
- Create a snapshot of the
PHP-fe-1
instance.- Use the snapshot to create two additional instances:
PHP-fe-2
andPHP-fe-3
. - Verify that both new instances function at http://INSTANCEIP.
- Attach
PHP-fe-1
,PHP-fe-2
, andPHP-fe-3
to thetodo-lb
load balancer. - Navigate to the DNS endpoint of the load balancer and ensure it functions correctly. Refresh the page and make sure that the IP address changes between front end servers.
- Stop two instances and ensure that there is no service interuption.
- Use the snapshot to create two additional instances:
- Create a snapshot of the