Discourse is a new generation discussion forum. I found that Discourse is very suitable for personal note taking. One notable feature of Discourse is that the users can focus on conversations. Besides, it supports Markdown as the message markup language. This is the reason why I like it very much.
To install Discourse, there are five essential steps:
Setup the Mail Server
It is required to have a mail server for Discourse. If you already have one, then just use it. If you don't have a mail server, then you can register one for free at SparkPost, which allows you to send 10k e-mails per month.
Visit SparkPost and click the TRY FOR FREE button on the top right corner.
Sign up for SparkPost.
- Fill in the e-mail and the password.
- Solve the CAPTCHA.
- Click the Sign Up button.
Verify your account by clicking the links in the confirmation e-mail.
Note: If you didn't receive the confirmation e-mail, you can request a new e-mail by clicking "ACCOUNT -> SENDING DOMAINS" and click the link in the top bar.
Before we can send e-mails with SparkPost, we have to claim that we are the owner of a domain name. This will require us to configure the DNS records.
- Click "ACCOUNT -> SENDING DOMAINS".
- Click the NEW DOMAIN button.
- Fill in the domain name and click ADD DOMAIN.
- Update DNS records for SPF and DKIM. Click the Configure link for more details. In summary, you have to add two different TXT records.
- After updating the DNS TXT records, click the Test links for verification.
Create a new API key.
- Click "ACCOUNT -> API & SMTP".
- Click the "NEW API KEY" button.
- Fill in the API Key Name, e.g. "discourse".
- Select the Send via SMTP in the API Permissions section.
- Fill in the SparkPost password again.
- Copy the API key.
Create a Droplet
After logging into Digital Ocean, click on the Create Droplet button on the top right corner. In the new page, you have to fill in the following fields:
- Droplet Hostname -- Choose a good name for your installation.
- Select Size -- All plans are fine. I tried the cheapest $5/mo plan, and it works perfectly.
- Select Region -- Choose a region for the data center. I chose New York data center. Pick one which is close to your visitors.
- Select Image -- The default image, Ubuntu 14.04 x64, is suggested. It is recommended by the Discourse development team.
- Add your SSH public key to the Add SSH Keys section.
Now, we can click on the Create Droplet button and wait for a while.
After the droplet is created, then try to log in with
Note: You can check the SSH server fingerprint by clicking the Console Access button in the Digital Ocean admin console.
Setup the Swap File
Here are the instructions to setup the swap file:
# Create a new swap file. $ sudo fallocate -l 4G /swapfile # Change the file permission. $ sudo chmod 600 /swapfile # Format the swap file. $ sudo mkswap /swapfile # Enable the swap file. $ sudo swapon /swapfile # Check that the swap file has been enabled. $ sudo swapon -s Filenam Type Size Used Priority /swapfile file 4194300 0 -1 # Add the swap file to fstab $ sudo bash -c "echo '/swapfile none swap sw 0 0' >> /etc/fstab" # Reboot the machine now. $ sudo reboot
You can further tweak the configuration by reading: How to Add Swap on Ubuntu 14.04.
In this section, we would like to install Discourse. There are three steps:
- Harden Droplet - Make your Droplet much more secure.
- Install Docker - Install Docker for Discourse.
- Install Discourse - Install Discourse and modify the settings.
Before installing Discourse, it will be better to harden the Droplet. We should:
- Enable automatic upgrade
- Disable the root account
First, we can enable automatic upgrade with:
$ sudo dpkg-reconfigure -plow unattended-upgrades # Choose <yes> to enable automatic upgrade.
Second, we would like to disable the root accoount. However, before doing so, we have to create a new user account:
# Create a new user. $ sudo adduser [username] Enter new UNIX password: Retype new UNIX password: # Grant sudo access to that user. $ sudo visudo # ... Add "[username] ALL=(ALL:ALL) ALL" # Copy SSH keys. $ sudo mkdir -p /home/[username]/.ssh $ sudo cp /root/.ssh/authorized_keys /home/[username]/.ssh $ sudo chown -R [username]:[username] /home/[username]/.ssh # Logout. $ exit
Log in with the new account and disable the root account with:
# Lock the root password. $ sudo passwd -l root # Disable the ssh root login. $ sudo vi /etc/ssh/sshd_config # ... Change "PermitRootLogin" to "no" # Restart ssh server. $ sudo service ssh restart
To install Docker, run the following command:
$ wget -qO- https://get.docker.com/ | sudo sh
Now, we can install Discourse with:
# Switch to root user. $ sudo -s # Create a directory for Discourse. > mkdir /var/discourse # Clone the Discourse docker image. > git clone https://github.com/discourse/discourse_docker.git \ /var/discourse # Change the directory to /var/discourse. > cd /var/discourse # Copy the sample configuration. > cp samples/standalone.yml containers/app.yml # Edit the configuration. > vi containers/app.yml
It is mandatory to change the following fields:
- DISCOURSE_DEVELOPER_EMAILS - This is the e-mail that will be treat as the administrator of the Discourse installation.
- DISCOURSE_HOSTNAME - This is the domain name for your Discourse installation.
- Mail Server Configurations - These are the settings for the mail server.
Here we are using the SparkPost as the example.
- DISCOURSE_SMTP_ADDRESSES, e.g.
- DISCOURSE_SMTP_PORT, e.g.
- DISCOURSE_SMTP_USER_NAME, e.g.
- DISCOURSE_SMTP_PASSWORD - The API key that you have created (40-digit hexadecimals.)
- DISCOURSE_SMTP_ADDRESSES, e.g.
And then, we can bootstrap the installation with:
./launcher bootstrap app
This will take some time. Get a cup of coffee and wait for a while. :-)
After the bootstrap succeed, we can launch the Discourse installation with:
./launcher start app
Congratulations! You should be able to checkout the installation through your favorite browser!
Note: If you have SSL certificates, then don't register or input anything now.
Install SSL Certificate
If you have an SSL certificate, then it's time to install the SSL certificate now!
To install SSL certificate:
mkdir -p /var/discourse/shared/standalone/ssl
Copy the private key to
/var/discourse/shared/standalone/ssl/ssl.keyand the certificate to
Edit the configuration:
"templates/web.ssl.template.yml"to templates section.
"443:443"to the expose section.
Now, we should rebuild the container with:
# Rebuild the container. ./launcher rebuild app
As the last step of installation, we have to create an administrator account so that we can fill in several important settings and moderate the forum.
Create an Admin Account
Open the browser and visit your Discourse installation.
Click the Sign Up button on the top right corner.
Fill in the E-mail, Username, Name, and Password.
Note: To be an adminstrator, the e-mail must be identical to DISCOURSE_DEVELOPER_EMAILS specified in
Click the link in the verification e-mail.
http[s]://[domain-name]/adminand click Settings.
- Fill in the fields.
- If you have installed SSL certificate, check the "Security -> use https" field.
- If you want this Discourse installation work as a private installation,
then you can check the following check boxes:
- Login -> invite only
- Login -> login required
- Login -> must approve users
Install Discourse Tagging Plug-in
If you wish to install Discourse Tagging Plug-in, here are the instructions:
Append following line to hooks -> after_code -> exec -> cmd:
git clone https://github.com/discourse/discourse-tagging.git
Rebuild the container with
./launcher rebuild app
Open the admin console in the browser, and enable the plug-in at Plugins -> Plugins -> Settings -> tagging enabled.
These are my notes to get a Discourse installation. We have covered:
- Register a SparkPost account and create an API key.
- Create a droplet and enable the swap file.
- Install Discourse and fill in the necessary settings.
Hope you enjoy this. You can find more information in the Discourse GitHub repository.