Friday, April 1, 2022

Amazon Lightsail - A Easy Way To Deploy A Small Business LAMP Stack Website

Introduction  

Amazon launched Amazon Lightsail late 2016 as a way for small businesses to create and host their own website.  One way to build a website is to leverage LAMP (Linux Apache MySQL PHP) -  an open source software bundle that websites can use to server a web page (Apache), process inputs (PHP), and store/retrieve data (MySQL or MariaDB). I decided to take Amazon Lightsail for a test drive, using my locally working "Ravendale Community Exchange Board" as the example. 

 

 

Ravendale Community Exchange Board LAMP Prototyping on Local Macbook Pro

The Ravendale Community needed a web based exchange board for its citizens to post messages about items for sale and services offered. After the initial requirements were gathered, a prototype was built on a Macbook Pro. The development was done on Ubuntu OS, running inside a VirtualBox that was running on MacOS. XAMPP from apachefriends.org provided the LAMP stack software.




Amazon Lightsail sign up

Once you sign up for an AWS account, you are led to an AWS console. (The version shown here is from March 2022, but there is a new version of the Console out in April 2022). From here, you can pick specific services such as an EC2 instance or build a web app. It is from here that I picked Lightsail.


 

 

LAMP on Lightsail

A website requires a web server, database, and a language to process requests and responses. This is exactly what LAMP - a stack of software put together - can do. Here you can see that I configured a decent machine (2GB RAM, 1vCPU, 60GB SSD) as the server to host my LAMP. 




LAMP from  Bitnami on Lightsail

Bitnami is a company that makes bundles of software easy to download and use. This is what Lightsail uses for its LAMP delivery. This in contrast to apachefriends.org XAMPP that I used for my development environment. Let's see how it will go!

 


 

 

 
Lightsail SSH via Web Browser

On my Macbook Pro, I use "vi" in a terminal for all development. I tend to favor simple editors over GUI IDEA such as IntelliJ or VSCode (both are installed on my development machine). Lightsail makes a SSH shell easy to start up by pressing a button - which brings up a web browser with a terminal.  Note that I also have started a SSH session on my native Macbook Pro, but I would have had to download a license PEM file, change permissions, then start a "ssh" session in a terminal.





Command Line Tools (git, vi, ...) in Lightsail terminal 

Once a terminal to Lightsail is available, I can fully operate as though I am on my own Macbook Pro. For example, I can use "git" to pull source code for the project from github. From the command line, I can easily bring up MariaDB (which replaced MySQL to get away from Oracle) to pre-populate / migrate data into it. The vi editor, a super old and trusty command line editor, already had syntax highlighting on, so even an old language like PHP looks readable.




Lightsail Provides a Static IP Address - Exchange Users Only Need To Go To One Place

Think of this as a P.O. Box - if I bring down Lightsail and bring it back up, I normally would be assigned a new IP address. Which means I need to tell all exchange users to where to point. With a static IP address, users can just continue to use the same IP address to reach the exchange, regardless of what happens in the backgroud. 

 


 

 

 

Web Site Running on Lightsail

With a static public IP address available, residence of Ravendale can now browse and post on the exchange. 

Amazon Lightsail Cost

Pricing is not only transparent, it is low. For $3.5 / month, you get all the goodies of LAMP : Linux, Apache to serve web requests, PHP to process, and MariaDB for data storage. Everything is bundled together, so no need to hobble each component separate, incurring a separate bill for each (compute, network, database).



Conclusion

Amazon Lightsail provide a complete solution (compute, database, networking, easy to install LAMP) and makes building and hosting a website predictable, cheap, and easy.