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.
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:
vi /etc/fstab
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.
swapon -s
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.
vi /etc/sysconfig/docker
Comment out line 4.
#OPTIONS='--selinux-enabled'
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 discourse
under /var
and clone the Discourse repository.
mkdir /var/discourse
git clone https://github.com/discourse/discourse_docker.git /var/discourse
Go to the discourse
folder.
cd /var/discourse
Copy the Discourse configuration template file into the containers folder.
cp samples/standalone.yml containers/app.yml
Open the app.yml
with vi.
vi containers/app.yml
If you are using a 1GB VPS, set the db shared buffer as 128MB in app.yml
.
db_shared_buffers: "128MB"
Change UNICORN_WORKERS
to 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.
DISCOURSE_DEVELOPER_EMAILS: 'you@youremail.com'
Set the domain name for Discourse. For example, we set it as discourse.example.com
, that means it would be accessible at the URL http://discourse.example.com/
.
## 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 app.yml
as follows.
DISCOURSE_SMTP_ADDRESS: smtp.example.com # (mandatory)
DISCOURSE_SMTP_PORT: 587 # (optional)
DISCOURSE_SMTP_USER_NAME: your@example.com # (optional)
DISCOURSE_SMTP_PASSWORD: YOURPASSWORD # (optional)
DISCOURSE_SMTP_ENABLE_START_TLS: true # (optional, default true)
Save and exit app.yml
.
Run the command below to bootstrap Discourse.
./launcher bootstrap app
After the bootstrapping process has completed, start Discourse.
./launcher start app
On your client PC, input the domain name that you configured for Discourse in app.yml
. You will see your own instance of Discourse.
app.yml
to make Docker listen on port 8080../launcher rebuild app
to rebuild your Discourse instance.You could earn up to $300 by adding new articles