Implementing and Scaling a LAMP App in Lightsail

1.5 hours
  • 4 Learning Objectives

About this Hands-on Lab

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

  1. Make sure the region is set to us-east-1.
  2. Select the LAMP (PHP 5) blueprint.
  3. Select the 2 GB instance plan.
  4. Name the instance PHP-fe-1.

Create a Lightsail Database Instance

  1. Ensure the region is set to us-east-1.
  2. Pick the default MySQL version.
  3. Check the box next to Specify Login Credentials and enter your credentials. Use the password taskstasks.
  4. Select the High Availability plan.
  5. Select the 2 GB instance size.
  6. Name the database todo-db.

Create a Lightsail Load Balancer

  1. Ensure the region is set to us-east-1.
  2. Name the load balancer todo-lb.
Configure and deploy the application on a single instance.
  1. Log in to the PHP-fe-1 instance using SSH.
  2. Follow the steps listed at https://github.com/linuxacademy/aws-lightsail-deep-dive/blob/master/Scenario3/learning_activity_3/1_fe_monolith_commands.sh.
  3. Complete the application installation at http://INSTANCEIP/install.php.
  4. Verify that the application is functional at http://INSTANCEIP.
  5. Create the task remember to buy a cat.
Migrate the application to the managed database instance.
  1. 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.
Scale and load balance the front-end tier.
  1. Create a snapshot of the PHP-fe-1 instance.
    • Use the snapshot to create two additional instances: PHP-fe-2 and PHP-fe-3.
    • Verify that both new instances function at http://INSTANCEIP.
    • Attach PHP-fe-1, PHP-fe-2, and PHP-fe-3 to the todo-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.

Additional Resources

Make sure you are in the us-east-1 region. Use the provided credentials to log in to the AWS management console.

Follow the steps below. You can either attempt to complete the steps on your own and then watch the videos to check your solution, or follow along with the videos to complete the tasks — the choice is yours.

Click the question marks below to view more details for each task.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?