Discourse is a new open-source forum solution which is simple, clean, and straightforward. It is implemented with Ruby on Rails, a Postgres database, and a Redis server cache. This tutorial describes how to install Discourse on a Vultr VPS with CentOS 7.
- Vultr VPS with 1GB RAM minimum.
- CentOS 7 x64 installed on the VPS.
Set up swap file
You must set up swap for a 1GB RAM VPS. If your VPS has more than 1GB RAM, you can skip this step. We will create a 2GB swapfile for 1GB RAM VPS.
Create the swapfile.
dd if=/dev/zero of=/swapfile bs=1M count=2048 mkswap /swapfile chmod 600 /swapfile
Edit fstab to add the swapfile into file systems table.
Open fstab with vi:
Add the following line into the file:
/swapfile swap swap defaults 0 0
Set the swap usage policy. Only use the swapfile when the system memory is low.
sysctl -w vm.swappiness=10 echo vm.swappiness = 10 | tee -a /etc/sysctl.conf sysctl vm.vfs_cache_pressure=60 echo vm.vfs_cache_pressure = 60 | tee -a /etc/sysctl.conf
Enable the swapfile.
mount -a swapon -a
Check the swapfile state.
If the swapfile has been enabled, you will see the following information.
Filename Type Size Used Priority /swapfile file 2097148 0 -1
Run the command below to install Docker on CentOS 7.
yum install docker
If you have disabled SELinux, you'd better disable it in docker also.
Comment out line 4.
Start the docker service.
systemctl start docker systemctl enable docker
Please note that if you restart firewalld, you will need restart docker also. Because firewalld will remove the docker chain from iptables when it's restarted.
Create a folder named
/var and clone the Discourse repository.
mkdir /var/discourse git clone https://github.com/discourse/discourse_docker.git /var/discourse
Go to the
Copy the Discourse configuration template file into the containers folder.
cp samples/standalone.yml containers/app.yml
If you are using a 1GB VPS, set the db shared buffer as 128MB in
UNICORN_WORKERSto 2 for a 1GB RAM instance.
## With 2GB we recommend 3-4 workers, with 1GB only 2 UNICORN_WORKERS: 2
Set your email address for the admin account. You will need this email to register the admin account on your Discourse forum.
Set the domain name for Discourse. For example, we set it as
discourse.example.com, that means it would be accessible at the URL
## TODO: The domain name this Discourse instance will respond to DISCOURSE_HOSTNAME: 'discourse.example.com'
Configure your mail server for Discourse.
If your mail server is on the same server with Discourse, configure it as follows.
DISCOURSE_SMTP_ADDRESS: smtp.example.com # (mandatory) DISCOURSE_SMTP_PORT: 587 # (optional) DISCOURSE_SMTP_USER_NAME: YOUR_EMAIL_ACCOUNT # (optional) DISCOURSE_SMTP_PASSWORD: YOURPASSWORD # (optional) DISCOURSE_SMTP_ENABLE_START_TLS: flase # (optional, default true) DISCOURSE_SMTP_OPENSSL_VERIFY_MODE: none
If you use a remote SMTP server, please edit the
DISCOURSE_SMTP_ADDRESS: smtp.example.com # (mandatory) DISCOURSE_SMTP_PORT: 587 # (optional) DISCOURSE_SMTP_USER_NAME: firstname.lastname@example.org # (optional) DISCOURSE_SMTP_PASSWORD: YOURPASSWORD # (optional) DISCOURSE_SMTP_ENABLE_START_TLS: true # (optional, default true)
Save and exit
Bootstrap and start Discourse
Run the command below to bootstrap Discourse.
./launcher bootstrap app
After the bootstrapping process has completed, start Discourse.
./launcher start app
Open Discourse in your browser
On your client PC, input the domain name that you configured for Discourse in
app.yml. You will see your own instance of Discourse.
- By default, Docker will listen on port 80. If the port 80 has been used by Nginx or Apache already, you need move that service to another port; or change Docker to another port. For example, change "80:80" to "8080:80" in
app.ymlto make Docker listen on port 8080.
- On the 1GB RAM VPS, it may fail to update the Discourse to the new version, and you will see a "502 Bad Gateway" when accessing Discourse. The simple solution for this issue is to run
./launcher rebuild appto rebuild your Discourse instance.