Discourse is a free and open source community forum. Unlike other discussion forums, Discourse has a modern look and feel, it is also responsive. Discourse comes with many features such as community moderation, summarize topics and inline context. Discourse is available in more than 25 languages.
Discourse also features real time notifications, an overlay editor, desktop notifications, file attachments and much more. You can also configure Discourse for social logins and single sign on. It is SEO friendly and comes with many plugins to extend its features. Discourse is used by many prominent companies for community forums like New Relic, Twitter developers forum etc.
In this tutorial we will be installing Discourse community forum on CentOS 7 using Docker.
To install Discourse Community Forum you will need a server or VPS with at least 1 GB RAM which is enough to serve small to moderate forum. To follow this tutorial you will need a minimal CentOS 7 installation with sudo or root access on it. If you are logged in as non root user run sudo -i to switch to the root account. Additionally, you will also need a domain name or subdomain pointed towards your server.
Before installing any package it is recommended that you update the packages and repository using the following command.
yum -y update
Now you will need to install git. Run the following command to do so.
yum -y install git
Discourse needs a 2GB Swap file if you have a VPS with 2GB RAM or less. You can skip this step if you have more than 2 GB RAM. Run the following command to check if you already have a swap file created.
If you do not have a swap created, the command will not print any output. Now create a swap file of 2GB in root directory using following command.
dd if=/dev/zero of=/swapfile count=2048 bs=1MiB
It will take few seconds to create the swap file. You will get following output.
[root@liptan-pc ~]# dd if=/dev/zero of=/swapfile count=2048 bs=1MiB
2048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB) copied, 29.8985 s, 71.8 MB/s
Once done, modify the file permissions so that the swap file is only readable to the root account using following command.
chmod 600 /swapfile
Now tell the system to set up the swap space using following command.
You should get following output.
[root@liptan-pc ~]# mkswap /swapfile
Setting up swapspace version 1, size = 2097148 KiB
no label, UUID=b26c5ac6-6c5a-4a0b-9776-aaf3fd72f18b
Now make the swap file permanent by editing /etc/fstab file in your favorite editor.
If you don't have nano install, run yum -y install nano to install nano editor. Now add the following line at the end of the file.
/swapfile swap swap sw 0 0
If you don't make the swap file permanent then your system will not use the swap file after reboot. Now tell the system to use the swap file using the following command.
Now you can check if the swap file is mounted is created or not using following command.
You will get following output.
[root@liptan-pc ~]# swapon -s
Filename Type Size Used Priority
/swapfile file 2097148 0 -1
Change the swappiness value of your system to 10 using the following command.
The swappiness value tells the system how often the system swaps data from memory to swap space. The above swappiness setting also restores if not made permanent. Edit /etc/sysctl.conf file using your favorite editor.
Now add the following line at the end of the file.
vm.swappiness = 10
Another configuration you might want to change is the cache pressure. Run the following command to change the cache pressure to optimal value.
The above swappiness setting also restores if not made permanent. Edit /etc/sysctl.conf file using your favorite editor.
Add the following line to the end of file.
vm.vfs_cache_pressure = 50
You can now check if your swap file is used as memory using the following command.
The output should include the swap memory as shown in the following output.
[root@liptan-pc ~]# free -m
total used free shared buff/cache available
Mem: 991 70 69 12 852 743
Swap: 2047 0 2047
As we have the swap file created, we can proceed to the next step of installation.
Install Docker using following command.
wget -qO- https://get.docker.com/ | sh
If you do not have wget installed, you can install it using yum -y install wget. The above command will detect your operating system and download and install the latest version of Docker in your system. Before using Docker, you will need to log out from current session and log back in again.
Now start the docker service and enable it to start at boot time using following command.
systemctl start dockersystemctl enable docker
Once the docker is running, make a new directory for Discourse docker files using the following command.
Now clone the Docker image of Discourse application using following command.
Now switch to the newly created directory using following command.
Now you will need to copy the template of configuration file so that we can use it. Run the following command for same.
cp samples/standalone.yml containers/app.yml
Now edit the configuration file using your favorite text editor.
Find the following line.
Uncomment it and change its value to 128MB if you have 1GB actual memory or 256MB if you have 2GB actual memory in your system.
Next find the following line.
Uncomment it and change the value of unicorn workers to 2 if you have 1GB actual memory or 3 or 4 if you have 2GB or more actual memory in your system.
Next, find the following line.
Change the value of discourse hostname to your domain name or subdomain.
Now find the following line.
Change the email address to the admin email address. You can use more than one email address separated by comma. These email addresses will be made administrator upon initial signup. Next find the following lines.
## TODO: The SMTP mail server used to validate new accounts and send notifications
DISCOURSE_SMTP_ADDRESS: smtp.example.com # required
#DISCOURSE_SMTP_PORT: 587 # (optional, default 587)
#DISCOURSE_SMTP_USER_NAME: email@example.com # required
#DISCOURSE_SMTP_PASSWORD: pa$$word # required, WARNING the char '#' in pw can cause problems!
#DISCOURSE_SMTP_ENABLE_START_TLS: true # (optional, default true)
It is very important to provide the email configuration, otherwise your site may break. Users are also sent an email before creation of a new account. Provide the address to the SMTP server in DISCOURSE_SMTP_ADDRESS. Uncomment the line and change the port to the value on which your SMTP server is listening to. In most cases SMTP runs on either port 587 or 465 or 25. Next uncomment the lines for SMTP username and password and provide the appropriate values in it. You should also uncomment the DISCOURSE_SMTP_ENABLE_START_TLSline and leave the the value true if your SMTP server can be connected using TLS. If the SMTP server is running on unsecured connection than change its value to false. Generally an SMTP server is listening to port 587 or 465 connects on secured connection wheres 25 connects on unsecured connection.
Looking for the right web hosting solution for your website can be an intimidating task. Options nowadays are more diversified than ever, and each year brings new developments in the web hosting market. If you have no clue of what to look out for, you can find yourself overwhelmed with...
Content marketing continues to be one of the most valuable tools for today’s online businesses. With content, you can improve your chances of reaching your target audience, boost your search engine standing, and even unlock new opportunities for sales. The more content you produce, the more you can strengthen your...
User Experience (UX) is one of the most crucial factors to consider in web design. As the number of websites and applications in the world today continues to accelerate, businesses are under more pressure than ever to impress customers straight away. If a user visits your website and finds slow-loading...