Getting Started with LAMP Stack Hosting on Amazon Lightsail

Celestina OdiliCelestina Odili
2 min read

What is LAMP Stack?

LAMP is a popular open-source software stack used for building and hosting dynamic websites and web applications.

LAMP stands for:

  • Linux (Operating System)

  • Apache (Web Server)

  • MySQL/MariaDB (Database)

  • PHP (Scripting Language)

Together they create a robust platform that powers a significant portion of the web. LAMP is known for its simplicity, flexibility, and strong community support, making it a go-to choice for developers deploying web applications, especially on platforms like Amazon Lightsail which offers easy provisioning and scalability.

Step-by-Step Guide

Step 1: Sign in to AWS

Step 2: Create a LAMP Instance

  1. Click “Create instance”

  2. Under Instance location, Choose Change AWS Region and Availability Zone and select your desired location.

  3. Under pick your instance image

    • Select a Platform: choose Linux/Unix

    • Select a Blueprint: choose LAMP (PHP 8)

  4. Install the application code: Use launch script to add a shell script that will run in your instance the first time it launches. Choose +Add launch script and add the following script;

     # remove default website
     #-----------------------
     cd /opt/bitnami/apache2/htdocs 
     rm -rf *
    
     # clone github repo
     #------------------
     git clone -b loft https://github.com/mikegcoleman/todo-php .
    
     # set write permissions on the settings file
     #-----------------------------------
     sudo chown bitnami:daemon connectvalues.php
     chmod 666 connectvalues.php
    
     # inject database password into configuration file
     #-------------------------------------------------
     sed -i.bak "s/<password>/$(cat /home/bitnami/bitnami_application_password)/;" /opt/bitnami/apache2/htdocs/connectvalues.php
    
     # create database
     #----------------
     cat /home/bitnami/htdocs/data/init.sql | /opt/bitnami/mariadb/bin/mysql -u root -p$(cat /home/bitnami/bitnami_application_password)
    
  5. Choose an Instance Plan. Lightsail instance plan is a low, predictable-cost, machine configuration (RAM, SSD, vCPU), and data transfer allowance.

  6. Choose the free tier instance plan. There are 90 days free plans. For testing, $5 plan is good.

  7. Provide a unique name for your instance

  8. Click Create Instance

Step 3: Test the application

The application start-up takes a few minutes. Once the status is listed as Running, note the instance’s IP address.

In your web browser, navigate to the instance’s IP address. You should see the application running.

Step 4: Clean up

To avoid unintended charges, delete resources that you are no longer using. This is a best practice. To delete the instance, follow these instructions:

  • Right click on the ellipsis (⋮) icon next to your LAMP instance and choose Delete.

  • Select Yes, delete when prompted

0
Subscribe to my newsletter

Read articles from Celestina Odili directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Celestina Odili
Celestina Odili

Computer Scientist/ Cloud Engineer/DevOps Engineer / Technical writer