In this section we’ll update the application configuration file (config.php) to point to our highly-available Lightsail database.
From the Lightsail console home page select Databases from the horizontal menu
Click on the name of the Lightsail database you created earlier
Under Connection details make note point of the value for Endpoint.
Create an environment variable (LS_ENDPOINT) to hold the value of your databases endpoint. For example:
LS_ENDPOINT='ls-1caf883f5883153cbe5324a8eab2b45eee39d38c.cdekwlh0imih.us-west-2.rds.amazonaws.com'
Be sure to use your own value. Do not copy and paste the value above.
Now set environment variables for the default username (dbmasteruser) and the password you created earlier (taskstasks)
LS_USERNAME=dbmasteruser && LS_PASSWORD=taskstasks
Check to make sure the envrionment variables are set correctly:
echo "Endpoint = "$LS_ENDPOINT && echo "Username = "$LS_USERNAME && echo "Password = "$LS_PASSWORD
Create a new configuration file that points to the Lightsail database. The command below uses sed to replace the values of of the default configuration file with the specific parameters to connect to your Lightsail database:
cat /opt/bitnami/apache2/configs/config.php.bak | \
sed "s/<endpoint>/$LS_ENDPOINT/; \
s/<username>/$LS_USERNAME/; \
s/<password>/$LS_PASSWORD/;" \
>> /opt/bitnami/apache2/configs/config.php.lightsail_db
Verify the file was modified appropriately
cat /opt/bitnami/apache2/configs/config.php.lightsail_db
Activate the new configuration
cp /opt/bitnami/apache2/configs/config.php.lightsail_db /opt/bitnami/apache2/configs/config.php
Verify that the active configuration file was modified
cat /opt/bitnami/apache2/configs/config.php
The database needs to be initalized. In a real-world deployment you would have processes to handle this, however for this demo you will simply execute a PHP script. Run the install.php script to configure the database by visiting http://<your lightsail instance public IP>/install.php.

Test the database connection by visiting http://<your lightsail instance public IP>/
. You should see no entries in the todo list. Go ahead and add a few to make sure everything is working.