How to setup Discourse on Azure


(Blake Erickson) #1

This guide is for those who are interested in self-hosting a Discourse site in Azure and will walk you through the initial Azure Portal details needed to get your Linux VM created so that you can then follow the regular cloud install guide that is web host agnostic. If you are not interested in self-hosting but would like us to host your Discourse forum for you please sign-up here.

1) Create a Resource Group

Before we create the VM, lets create a Resource Group. This is where everything related to your Discourse site will live like your VM storage disks, networking, security groups, blob storage, etc. To create a Resource Group click the green plus sign and select Resource Group, then fill out the “Resource group name” field, select your “Subscription”, and your “Resource group location”, then press “Create”.

image

2) Create the Linux VM

We are going to create an Ubuntu 16.04 LTS VM for this guide, to do that click the green plus sign again and then search for “Ubuntu Server 16.04 LTS” and it should show up as one of the available VM’s.

Select it, and then make sure the deployment model is on “Resource Manager” and then click “Create”

3) Configure basic settings

Now you should be on the “Basics” tab of “Create a virtual machine”. Fill out all the required fields to setup the VM. Select the “discourse” resource group we created earlier, give your VM a name like “discourse”, and choose the Region you would like to use.

Still on the same “Basics” tab you will need to choose the size of your VM. It defaults to a “Standard D2s v3” which has 8 GB of memory and costs $71.42 per month, so be sure to select “Change size” and choose an appropriate VM size for your workload.

image

For the bare minimum you will need to select the “B1ms” option with 2GB of ram. The “B1s” even though it is advertised with having 1GB you only get around 800MB of ram at the OS level and there just isn’t enough left over to run Discourse well. The “B1ms” will cost $17.11 per month.

Now fill out the Linux username, and upload your ssh public key. Alternatively you can configure a password based login, but the ssh key based login is preferred.

Now we need to make sure we have web and ssh access to the machine by selecting the “Allow selected ports” radio button and choosing HTTP, HTTPS, and SSH from the “Select inbound ports” dropdown. After setup is complete it is a good idea to limit ssh access to only your IP Address.

Select “Review + create”. Verify everything is good on the Summary page and then press “Create”. The VM creation will take several minutes.

4) SSH into the VM

We will need command-line access in order to setup swap and to install Discourse. Once the VM has been created you should be able to select it from the azure portal and on the Overview screen it will display the Public IP address. Open your terminal and ssh into the VM with the username we specified in step 3 of this guide.

If you are unsure how to SSH into the VM you can alternatively use the “Serial console” inside of the Azure Portal by selecting the VM and at the bottom of the navigation on the left you can select “Serial console”.

This will open up a shell where you can type in your username and password that you specified before you created the VM. If you are unsure what your password is you can use the “Reset password” option.

You should now be at a terminal where you can type commands:

5) Setting up Swap

Each azure VM comes with a temporary disk separate from your OS disk and is usually mounted at /dev/sdb1. You want to make sure your swap is setup on this temporary disk and not your OS disk because:

This temporary storage drive is present on the physical machine which is hosting your VM and hence can have higher IOPS and lower latency when compared to the persistent storage like data disk. - Understanding the temporary drive on Azure Virtual Machines

Edit the /etc/waagent.conf file and update the following lines:

ResourceDisk.Format=y
ResourceDisk.EnableSwap=y
ResourceDisk.SwapSizeMB=2048

Note: If you already have a swap setup on the OS drive (maybe because ./discourse-setup configured it for you) you can turn it off by commenting out the /swapfile line in /etc/fstab.

If you are unsure how to edit the /etc/waagent.conf file with a command-line editor like vim you can simply copy+paste the following command into your terminal and press enter:

sudo sed -i '/ResourceDisk.Format=n/c\ResourceDisk.Format=y' /etc/waagent.conf && sudo sed -i '/ResourceDisk.EnableSwap=n/c\ResourceDisk.EnableSwap=y' /etc/waagent.conf && sudo sed -i '/ResourceDisk.SwapSizeMB=0/c\ResourceDisk.SwapSizeMB=2048' /etc/waagent.conf

It may ask you for you password if this is the first time you’ve run a sudo command.

Then restart your VM with sudo shutdown -r now.

To verify that swap is working log back into your VM and type swapon --show and you should see something like:

root@azure:~# swapon --show
NAME          TYPE SIZE USED PRIO
/mnt/swapfile file   2G 0B   -2

Notice that the swap file is located inside of /mnt this is good because this is our temporary drive.

You can also type free -h and see something like:

root@azure:~# free -h
              total        used        free      shared  buff/cache   available
Mem:           1.9G        174M        1.5G        3.0M        172M        1.5G
Swap:          2.0G          0B        2.0G

The swap should have something in the total column which means it has been setup.

6) Install Discourse

Now that our Linux VM has been created on Azure and we have a swap partition it is now time to follow the Official Cloud Install Guide.

7) Install the Azure Blob Storage Plugin (Optional)

Now that Discourse is installed you can follow the install instructions on the Azure Blob Storage Plugin topic. Installing and enabling this plugin will cause images that users upload to be stored in blob storage instead of on your Linux VM which should help with performance as well as keeping your OS disk from filling up.


Could you please upload the basic installing tutorial video for Ubuntu Server 18.04 LTS
Could you please upload the basic installing tutorial video for Ubuntu Server 18.04 LTS
New Discourse Instance + SMTP