In this section we are going to deploy the application code into our lightsail instance, as well as configure the connection between the PHP applicaiton and the locally-running MySQL database.
The following steps are performed from the LAMP instance command line using either your own SSH client or Lightsail’s web-based SSH access.
SSH into your LAMP instance (php-fe-1). If you need a primer on how to SSH into a Lightsail instance, visit Using SSH with Lightsail at the top of the left hand menu.
The LAMP Bitnami image has some default web pages installed, you will need to remove those so you can deploy the PHP application.
cd /opt/bitnami/apache2/htdocs && rm -rf *
Use git to clone the appication code onto the server
git clone https://github.com/mikegcoleman/todo-php .
The PHP application uses a file (config.php) to hold the information necessary to connect to the database (database host name, username, and password). You will need to create a directory to house our configuration files and make the bitnami user the owner.
sudo mkdir /opt/bitnami/apache2/configs && \
sudo chown bitnami:bitnami /opt/bitnami/apache2/configs
As a best practice never store sensitive information in the document root of your web server. Ideally, in production you would use a secrets management solution such as AWS Secrets Manager.
Move the config file into the configuaration directory
sudo mv /opt/bitnami/apache2/htdocs/config.php /opt/bitnami/apache2/configs/config.php
In the next section you’ll supply values to the configuration file that will allow the PHP front end to talk to the Lightsail database.