This guide will walk you through setting up an Amazon Lightsail instance with a LAMP stack using PHP 8, and configuring it to deploy a PHP application from GitHub with database setup.
If you haven't already, create an Amazon Lightsail account at AWS Lightsail.
-
Select Linux/Unix platform and choose LAMP (PHP 8) as your blueprint.
-
Click on +Add launch script and paste the following script into the launch script text window.
# 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)