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.
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
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, orforum.example.comto 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
Arecord 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.
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.comto 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 theyum-cronpackage. - 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-cracklibpackage. We recommend usingfail2ban, 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)
- Ubuntu:
- If you wish to install a firewall by default, enable ufw on Ubuntu or use
firewalldon 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





