This guide will help you install the Discourse forum software on Ubuntu 18.04.4 LTS AWS EC2 instance with domain routing on AWS Route 53, SMTP on AWS SES and SSL certificate.
About Discourse : Discourse is an open source, feature rich forum software built and managed by one of the most amazing teams on the internet today. Its also led by the great Jeff Atwood, this guy is a genius, he is also the co founder and developer of stackexchange.com, yes he is great. I highly recommend reading his blog ( Source to his blog ), which is well written and maintained for over 15 years !!! Yes very few blogs like his on the internet.
Discourse allows people like me, to have a fully functional forum software, almost like Wordpress for web sites, and its awesome. Check out this website I made with discourse in just a couple of hours to track and have a conversation regarding the ongoing Covid-19 pandemic : colloquium-19 .
Hardware Requirements for Discourse:
- modern single core CPU, dual core recommended
- 1 GB RAM minimum (with swap)
- 64 bit Linux compatible with Docker
- 10 GB disk space minimum
- Email address
- Amazon Web Services account
- SMTP details from Amazon SES
- A domain name
Github link : https://github.com/discourse/discourse
For this set up we will be using the following services on AWS:
1- AMAZON EC2 - Ubuntu 18.04.4 LTS instance.
2- AMAZON Simple Email Service ( SES) - SMTP
3- Route 53 domain hosting and routing.
Along with AWS we shall use the following software packages through their command line interfaces:
Step 1 : Configure Ubuntu on AWS EC2
1- Login to AWS - https://aws.amazon.com/
If you do not have an AWS account , you can sign up for a free trial and you will receive 750 hours of EC2 compute hours, 5 GB of S3 storage and many other great Amazon Web services for free, for the first 12 months.
2- Once you have created your account navigate to the EC2 option under compute, when you click on the services menu.
Once your in the Instances dashboard, at this point my suggestion would be to select the correct region in AWS. For this example and many of my projects I use North Virginia Usa east-1, due to a host of reasons like : cost , latency , & features,
3- Choose the region which is closest to you or your target market, from the drop down menu on the top right.
4- Click on the instances option on the left menu bar.
5- Now select the blue colored launch Instance button
Next you will find your self in the AWS market place , here you can find the list of all images of the operating systems available on AWS EC2.
6- In the top search bar type in Ubuntu , the first option that will be displayed is the ubuntu configuration we are looking for : Ubuntu Server 18.04 LTS (HVM). Select the instance by clicking the blue select button on the right.
Select the instance type, for a fully functional website with 1000's of users, you should use at least a t3a.small instance with 2 GB of RAM memory and 2 Virtual cpus, that can be utilized to handle heavier work loads. For this example we will use a t2.micro instance, which is eligible for the free tier usage by AWS, it has 1 GB RAM and 1 Vcpu , the bare minimum required to run Discourse.
7- Select t2.micro , with 1 GB Memory RAM and 1 Vcpu.
8- Next click configure instance details , do not change anything here, click on Next:add storage.
Click add storage, the next part is important as AWS by default allocates only 8 GB of SSD memory to your instance. The required memory is at least 10 GB, not including back ups. My recommendation is to allocate at least 20 GB of memory to your EC2 instance, in case you will be utilizing heavy images and expect many users.
9- Allocate 20 GB of memory to your instance.
10- First name the security group, here we have name it as: launch-wizard-Discourse, then click add rule and add HTTPS, HTTP, SMTP, with default port numbers 443,80, and 25. SSH will be enabled by default , but my recommendation is to white list only your IP address, in the source section, to prevent any attacks.
11- Click review and launch, take the time to check your instance settings.
12- Click Launch.
At this point you will be prompted to select an existing authentication key or use a pre-existing one. For the sake of safety I would suggest you to create a new key pair, this is important as using the key is the only way you will be able to login to your instance.
13- Select create a new key pair from the drop down menu, and name the key pair, here we have used : Discourse_key1. Then click the download Key pair button and save the .PEM file in a secure location, your file will be name : Discourse_key1.pem.
14- Then click launch instances.
Step 2 : Configure SMTP on Amazon Simple Email Service.
Configuring SMTP is a very important step, as Discourse will not be able to send the account activation email without it.
Port:25, 465 or 587
Step 3 : Configure DNS and hosting on Amazon Route 53.
1- Navigate to Route 53 under the services menu in AWS and purchase a domain name if you do not already have one, then click on Hosted zones button.
Step 4 : Installing Discourse on Ubuntu 18.04.4 LTS ( AWS EC2 instance)
1- Login to your Ubuntu instance, open an SSH client (connect using PuTTY)
2- Locate your private key file (Discourse_key1.pem). The wizard automatically detects the key you used to launch the instance.
3- Your key must not be publicly view-able for SSH to work. Use this command if needed :
chmod 400 Discourse_key1.pem
ssh -i "Discourse_key1.pem" firstname.lastname@example.org
sudo apt update
sudo apt upgrade -y
6- Install Docker, Run the below command to install the latest version of docker :
wget -qO- https://get.docker.com/ | sh
7- Check your docker version and running status with the below commands :
systemctl status docker
sudo mkdir /var/discourse
sudo git clone https://github.com/discourse/discourse_docker.git /var/discourse
sudo su -
Hostname for your Discourse? [discourse.example.com]: www.forgify.io // use activated domain email//
Email address for admin account(s)?: email@example.com, // Use verified email //
SMTP server address? [smtp.example.com]:email-smtp.us-east-1.amazonaws.com
SMTP port? : 465
SMTP user name? [firstname.lastname@example.org]: Aasdwfewfc@#$#@ **
SMTP password? [pa$$word]: BL3456gdsDFEFS
Optional email address for setting up Let's Encrypt? (ENTER to skip) [email@example.com]: firstname.lastname@example.org
./launcher rebuild app