Flarum Connects to AWS RDs

For the majority tutorial, the flarum always connects with the localhost db directly. However, base on my knowledge, once the server shutdown or reboot, the data could be lost, also it’s not easy to debug(although flaurm has logs files to record all errors). So I suppose that separate db and flaurm server.

In this section, I use AWS EC2 and RDs to implement my solution.

For how to deploy the Flarum in EC2, I will write author article, but to be honest, it’s the common way for deploying to any other Linux server.

Preparation

  1. Creating a Database
  2. Setting the security group
  3. Testing locally(I use navicat)
  4. Updating the config.php in Flarum

Creating a Database

Here I choose the free tier of RDs which only for the new register user in 12 months.

1. Navigate to RDS

2. Create a DB

Here is my choice, I use mysql and free tier type.

Here I select public access directly, because I need to test the connection and create flarum_db locally. (If you forget, just click [modify] button to select the option)

3. Waiting for initialization

Then the new record has created now.

In the Connectivity & security , Endpoint is the connection link.

Update the security group

Although, It can be accessed publicly, but might show [1002 fail connect to db ] error.

Click [VPC security groups] to navigate to the Security Groups panel. Edit the Inbound rule.

Turn on 3360 port is necessary, and I allow all the traffic to access(In production env, need to delete)

Testing locally

1. Create a new connection

Paste the Endpoint and the username/password, and test connection. In my case, it connects to RDs expectly.

Flarum part

If You have deployed Flarum before, just change the config.php. If You are in the initialization step, just directly fill in RDs.

Here is the CLI to the folder I deploy the flarum.

1
2
3
4
5
6
7
8
cd /var/www/html/forum/
// admin role
sudo su
ls
vim config.php 

//exist and save
:wq

Thanks!