discourse multiple installations

How to install Multiple discourse on one server

There is no official guide on how to install multiple discourse instances on one cloud server by discourse team , so i created this full guide to support people like me who are searching for configurations on official discourse forum and still not able to succeed

I am using digital Ocean Ubuntu18,2GB RAM/50GB hard disk droplet

If you want me to install multiple discourse then click here

Lets start

  1. Installing first discourse

sudo mkdir /var/discourse

wget -qO- https://get.docker.io/ | sh

git clone https://github.com/discourse/discourse_docker.git /var/discourse

cd /var/discourse
sudo cp samples/standalone.yml containers/app.yml
sudo nano containers/app.yml

edit you app.yml file and add host name,smtp,email

sudo ./launcher bootstrap app
sudo ./launcher start app

And you will be able to see the discourse page on your host example.com in browser

Now if everything is working fine lets start 2nd installation

we have to install nginx to create proxy pass for discourse but we have to create nginx outside our container , so stop the first app.yml container

cd /var/discourse

./launcher stop app

install nginx now with below commands

sudo apt update

sudo apt install nginx

systemctl status nginx

after status nginx you will see output like below

below are the nginx commands you dont have to use any command if nginx is running these are for info purpose only:

sudo systemctl stop nginx

To start the web server when it is stopped, type:

sudo systemctl start nginx

To stop and then start the service again, type:

sudo systemctl restart nginx

If you are simply making configuration changes, Nginx can often reload without dropping connections. To do this, type:

sudo systemctl reload nginx

By default, Nginx is configured to start automatically when the server boots. If this is not what you want, you can disable this behavior by typing:

sudo systemctl disable nginx

To re-enable the service to start up at boot, you can type:

sudo systemctl enable nginx

now we have installed nginx ,go to cd /var/discourse

and edit your app.yml file by

nano containers/app.yml (is nano is not installed install it by sudo apt-get install nano or for centos sudo yum install nano

edit your app.yml file templates same like below and delete expose section

— “templates/postgres.template.yml”

— “templates/redis.template.yml”

— “templates/sshd.template.yml”

— “templates/web.template.yml”

— “templates/web.ratelimited.template.yml” — “templates/web.socketed.template.yml”

#expose: # comment out entire section

first we installed discourse on ports now we are editing it again to work with nginx this is our first site and second is not yet started , now we will add conf file in nginx to listen our website

so go to

cd /etc/nginx/sites-enabed/

now add new file here discourse.conf by

touch discourse.conf

now edit this new file with

nano discourse.conf

copy paste below code and add in discourse.conf(change server name to host name (website name )

server {
listen 80; listen [::]:80;
server_name example.com; # ← change this

location / {
proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock:; # ←- volume: same like yml file
proxy_set_header Host $http_host;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
}
}

now cd …

sudo nginx -t (if ok then proceed)

systemctl stop nginx

systemctl start nginx

sudo service nginx reload

now we have done nginx conf file we will rebuild our first site

/var/discourse/launcher stop app

/var/discourse/launcher rebuild app

after rebuild you can log in to your website and you will see your first website running discourse

now again stop app

/var/discourse/launcher stop app

and then create second .yml file for second discourse we will name it to app2.yml

sudo cp contaiiners/app.yml containers/app2.yml

now we have second app2.yml file same copy of app.yml , we will edit it now

nano containers/app2.yml

change host name to new host name and smtp to new smtp (use new smtp always)

in app2.yml file you will see volume : /var/discourse/shared/standalone

change volume standalone to standalone2

save it and go to cd /etc/nginx/sites-enabled

create new discourse2.conf file with

touch discourse2.conf

nano discourse2.conf and add below script to it

server {
listen 80; listen [::]:80;
server_name examle.com; # ← change this

location / {
proxy_pass http://unix:/var/discourse/shared/standalone2/nginx.http.sock:; # ←- volume: same like yml file
proxy_set_header Host $http_host;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
}
}

now again

sudo nginx -t (if ok proceed)

systemctl stop nginx

systemctl start nginx

sudo service nginx reload

now rebuild secand app2.yml with

inside cd /var/discourse

./launcher rebuild app2

now your second discourse is live start first also with

./launcher start app

both containers are now live if you see blank page make sure you create swap and rebuild both app and app2

I hope my guide help you setting up 2+ forum on same droplet if you have any issue or if you want me to install discourse for you please contact me on fiverr and order gig click here

Back-end Developer