Discourse Official Install Guide | Discourse Cloud Platform Installation

This document is a translation of the content from the page discourse/docs/INSTALL-cloud.md at main · discourse/discourse · GitHub.

The original translation is published at: Discourse 云平台安装 - Discourse - iSharkFly , welcome to join the discussion.

Cloud Platform Installation

A Discourse installation on a cloud platform typically takes no more than 30 minutes, even if you have no knowledge of Rails or Linux shell. The following installation was tested using DigitalOcean as the service provider, but all installation steps can be performed on any cloud platform compatible with Docker, and can also be installed on a local server.

:bell: Don’t have even 30 minutes? You can contact the Discourse community to help you with the installation. The Discourse community charges a one-time fee of $150 (USD). Click here to purchase the service.

Prerequisites

Domain Name

:bell: Discourse cannot work with an IP address. You must have a domain name or a subdomain name for the installation, e.g., example.com.

  • If you already have a domain name, you can choose any subdomain for the installation, such as discourse.example.com, talk.example.com, or forum.example.com to install your Discourse instance.
  • If you don’t have a domain name yet, you can visit NameCheap to search for your preferred domain name, or simply search Google for great domain name registrars to choose your preferred domain registrar.
  • Your DNS console should be accessible. After purchasing your domain name, you will need to access your DNS configuration to set up DNS. For your Discourse website installation, you need to create an A record through your DNS. This A record needs to point the domain name you want to install to a specific IP address. This IP address is usually the IP address of the server you purchased in the first step.

Email

:warning: The email system is very important for Discourse user creation. If you do not set up an email SMTP server before installing Discourse, your Discourse installation will be inaccessible and you will not be able to log in (HAVE A BROKEN SITE)!

  • If you already have your own SMTP mail server, you can use your existing mail server configuration information directly.
  • Still don’t have a mail server? Please visit Discourse Recommended Mail Servers.
  • To ensure your emails are delivered correctly, you must add valid SPF and DKIM records to your DNS. Please refer to your email service provider’s documentation on how to set these up.

Based on our actual usage, Discourse installation must be configured with an available domain name and mail server. For mainland China, you can use enterprise email services provided by Alibaba Cloud or Tencent Cloud. We generally recommend using an overseas mail server, such as AWS SES or MailGun, which are good services. You may need an international credit card for verification. But this step is mandatory, otherwise your Discourse cannot be installed.

Installation

Create a New Cloud Server

Create your new cloud server, for example, DigitalOcean. Of course, you can also use servers provided by other platforms.

If you choose a server located within mainland China, you are likely to encounter some network issues. This translation has an additional section to address network problems.

  • The default configuration of the current version of LTS Ubuntu operating system works well. At a minimum, a 64-bit Linux operating system is required, and its kernel needs to be updated to the latest version.
  • The default configuration of 1 GB of memory is usually sufficient for small Discourse communities. However, we recommend 2 GB of memory for larger communities.
  • The default configuration of the New York data center is a good geographical choice for North America and Europe. If your Discourse users are primarily in other geographical locations, you can choose a data center closer to them.
  • Enter the domain name discourse.example.com to create a Droplet (Droplet is the server name defined by DigitalOcean) in DigitalOcean. You can also purchase and use your own domain name. Discourse installation usually requires a real domain name and cannot be installed via IP address, so we recommend that you first purchase a domain name or use a subdomain of your existing domain name.

Creating your new Droplet is equivalent to creating a server on DigitalOcean, and also equivalent to creating a VPS or server on other platforms. Once created, you will receive an email containing your root user password. However, we recommend setting up SSH keys to enhance the security of your server access.

Access Your Cloud Server

Use the IP address and SSH to connect to and access the server you created. For Windows platforms, you can install Putty and run the following command to connect:

ssh root@192.168.1.1

If you have not configured SSH keys, you can use the password included in the email sent by DigitalOcean to log in, or use your local SSH keys to connect.

Install Docker / Git (Optional)

sudo apt install docker.io
sudo apt install git

If you wish to use your own version of Docker, you can install it on your newly configured server now. If Docker is not installed by default on your server, discourse-setup will automatically download and install it from get.docker.com.

Install Discourse

Clone the code from the official Discourse Docker installation repository to the /var/discourse directory on your local machine.

sudo -s
git clone https://github.com/discourse/discourse_docker.git /var/discourse
cd /var/discourse

You only need to execute the above commands. Root privileges are required during the Discourse installation process.

Add Docker Image (Mainland China Servers Only)

If your server is located in mainland China, you will likely get stuck at the Docker step in the following procedures. Please try adding a Docker image.

Using Tencent Cloud as an example, edit /etc/docker/daemon.json in Linux with your preferred editor and add the following content. You can try changing https://mirror.ccs.tencentyun.com to the Docker image URL provided by your cloud server vendor:

{
   "registry-mirrors": [
   "https://mirror.ccs.tencentyun.com"
  ]
}

After adding the Docker image, restart the Docker application to apply the changes using sudo systemctl restart docker.

Edit Discourse Configuration

Run the configuration tool with the following command:

./discourse-setup

You will need to configure all parameters according to the following prompts:

Hostname for your Discourse? [discourse.example.com]:
Email address for admin account(s)? [me@example.com,you@example.com]:
SMTP server address? [smtp.example.com]:
SMTP port? [587]:
SMTP user name? [user@example.com]:
SMTP password? [pa$word]:
Let's Encrypt account email? (ENTER to skip) [me@example.com]:

The input data above will create an app.yml file for your Discourse instance, which will be used to configure your Discourse instance after the installation. The entire installation startup process may take 2-8 minutes to configure Discourse for you. If the installation fails, or if you need to modify your configuration after installation, you can run the ./discourse-setup command again (this command will reload the existing app.yml file). Alternatively, you can manually edit the content of the /containers/app.yml file and then run ./launcher rebuild app again, otherwise your changes will not take effect.

Optimization for China Network Environment

If your cloud server is in mainland China, you are very likely to encounter network issues during the execution of ./discourse-setup or ./launcher rebuild app. Discourse has already prepared image services for you, excluding Docker. You only need to add one line in your containers/app.yml here:

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/web.china.template.yml" # Add this line to configure mirrors for package managers like npm, rubygems, etc.

This will resolve the issue.

Start Discourse

Once the initial installation configuration is complete, your Discourse instance should be accessible in your browser via the configured domain name discourse.example.com.

For servers located in mainland China, you may also need to complete the filing process according to your cloud server provider’s instructions before proceeding.

Register a New Administrator Account

Use the email address you entered during the setup process to register an administrator account.

(If you cannot register your administrator account, please check the logs at /var/discourse/shared/standalone/log/rails/production.log, or visit the Email Troubleshooting Checklist.)

After completing the administrator account registration, the setup wizard will start and guide you through configuring your Discourse instance.

Once all setup wizards are completed, you will see Staff topics and the READ ME FIRST: Admin Quick Start Guide. This setup guide will contain suggestions for subsequent configurations and how to customize your Discourse installation.

Post-Installation Maintenance

  • We strongly recommend enabling automatic security updates for your operating system. On Ubuntu, use the command dpkg-reconfigure -plow unattended-upgrades. On CentOS/RHEL, use the yum-cron package.
  • If you are using password login for your operating system instead of SSH keys, make sure to use strong passwords. On Ubuntu, use the apt-get install libpam-cracklib package. We recommend using fail2ban, which will ban IPs that have 3 failed login attempts for 10 minutes.
    • Ubuntu: apt-get install fail2ban
    • CentOS/RHEL: sudo yum install fail2ban (requires EPEL)
  • If you wish to install a firewall by default, enable ufw on Ubuntu or use firewalld on CentOS/RHEL 7 and later versions.

You will receive update notifications via email when new versions of Discourse are released. Please update your Discourse instance to the latest version at any time to ensure all security issues are fixed. You will get email reminders as new versions of Discourse are released. Please stay current to get the latest features and security fixes. To update Discourse to the latest version, visit /admin/upgrade through your browser and click the update button.

The launcher command in the /var/discourse directory is used for system-level maintenance:

Usage: launcher COMMAND CONFIG [--skip-prereqs] [--docker-args STRING]
Commands:
    start:      Start/initialize a container
    stop:       Stop a running container
    restart:    Restart a container
    destroy:    Stop and remove a container
    enter:      Use nsenter to get a shell into a container
    logs:       View the Docker logs for a container
    bootstrap:  Bootstrap a container for the config based on a template
    rebuild:    Rebuild a container (destroy old, bootstrap, start new)
    cleanup:    Remove all containers that have stopped for > 24 hours

Options:
    --skip-prereqs             Don't check launcher prerequisites
    --docker-args              Extra arguments to pass when running docker
5 Likes

The translation is good, thumbs up, hope the official can have a multilingual entry.

1 Like

Thank you.

We also found that there was very little Chinese content when using Discourse, but Discourse is still a very good platform.

There was a bit of difficulty and some prerequisites during installation, it’s not something that can be installed on any machine.

But basically, these can be bypassed quite well, so we thought we would submit some of what we have already published internally to the official site.

The official site is quite supportive and open, but we’re not sure how to organize it, and it seems a bit messy.

Gradually, we will also submit some of our existing articles to the official site.

3 Likes

There used to be a Chinese forum, but it seems to have shut down at the beginning of the year.

I still remember seeing this, and I even referred to some of their articles when installing it.

Perhaps the original moderator no longer has time to maintain it, as maintaining a website requires considerable energy and financial expenditure.

Since we are not very familiar with Discourse and have always used Discuz, and since DISCUZ has not been updated for many years after being acquired by Tencent, there are a lot of problems, and we cannot upgrade.

So I thought about finding a replacement, and then I found Discourse, and then I installed and used it, and it felt pretty good.

I’ve put some of our own usage experiences in our section: iSharkFly - 飞鲨

Slowly, I found that there is really too little Chinese information, so I thought about sharing some with the official website.

It’s really not easy to keep a website going. :slight_smile:

I hope everyone uses Discourse more. The more people use it, the more lively it will be, and the more interested we will be.

1 Like

@fantasticfears This seems to be the owner of the Chinese website… But the last visit was also in 2019. I don’t know if they forgot to renew the server or for what reason, the Chinese website suddenly disappeared.

Perhaps there was no time to deal with it.

It doesn’t matter, I’ll just hang out on the official forums. Heh heh.

For a Chinese community whose users are primarily Chinese, Discourse’s localization is still quite lacking. After all, user habits are different.

This is the truth, all those who use string mapping for translation have this problem.

The translated content strings and sorting are strange.

However, I think Discourse is still very good, especially the attachment upload, which is extremely convenient.

The content is in md format, and although it has a learning curve for ordinary users, it is sufficient.

Most importantly, data and storage are separated. This is something to praise, with almost unlimited attachment space, built-in CDN, and no need to worry about attachments for backups, which is great for those who like to take screenshots.

1 Like

OSSEZ community has adjusted its domain name, and this article is published at: Discourse 云平台安装 - Discourse - iSharkFly.

1 Like

Added the chapter “Optimization for the Chinese Network Environment” for you.

3 Likes