Secure the Server
Turn on automatic security updates.
$ sudo dpkg-reconfigure -plow unattended-upgrades
Setup a firewall with ufw.
$ sudo apt-get install ufw $ sudo ufw default allow outgoing $ sudo ufw default deny incoming $ sudo ufw allow 22 comment 'SSH' $ sudo ufw allow http comment 'HTTP' $ sudo ufw allow https comment 'HTTPS' $ sudo ufw enable
Install fail2ban to secure your server
$ sudo apt install fail2ban
Configure fail2ban to Use ufw
Copy the main configuration to avoid unexpected changes during package updates.
$ sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
Edit the configuration file with your favorite text editor
$ sudo nano /etc/fail2ban/jail.local
Change the banaction and banaction_allports settings to ufw in the file /etc/fail2ban/jail.local as follows:
banaction = ufw banaction_allports = ufw
Collect the SMTP Details
Next, you’ll need to collect the SMTP details from your transactional email account. You need the following information:
SMTP server address SMTP port SMTP user name SMTP password
*** This is important, if you don’t have a proper SMTP details, you might not properly install discourse at all.
Access Your Server
Connect to your server instance with SSH. For example, if your server’s IP address is 192.0.2.123:
$ ssh email@example.com
Docker is an open-source platform for developing, shipping, and running applications. Docker enables you to run Discourse in an isolated and optimized environment. Use these steps to install Docker on your server.
Uninstall old versions such as docker, docker.io, or docker-engine.
$ sudo apt-get remove docker docker-engine docker.io containerd runc
Set up the repository.
$ sudo apt-get update $ sudo apt-get install ca-certificates curl gnupg lsb-release $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg $ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null $ sudo apt update
Install the latest version of Docker Engine.
$ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
Create a ‘discourse’ folder in the /var directory.
$ mkdir /var/discourse
Clone the official Discourse git repository in /var/discourse.
$ git clone https://github.com/discourse/discourse_docker.git /var/discourse
Change to the Discourse directory.
$ cd /var/discourse
Launch the setup tool.
Answer the prompted questions with your hostname and SMTP details. The Discourse setup script may ask the following questions:
Hostname for your Discourse?: Enter your chosen hostname for your Discourse platform (for example, discourse.example.com). Email address for admin account(s)?: Choose the email address for your Discourse admin account. It can be any email address. When setting up the Discourse control panel, you need to reuse this email address. SMTP server address?: Enter your SMTP server address. For example, the SMTP server address for Sendgrid is smtp.sendgrid.net SMTP port?: Enter your SMTP port. For example, the SMTP port is 587. SMTP user name?: Enter your SMTP user name. For example, Mailgun provides you with a user name. For Sendgrid, you must set the user name precisely to the string apikey. SMTP password?: Enter your SMTP user password. For example, Mailgun provides you with a password. For Sendgrid, you can enter your generated API key. Press ENTER to confirm your settings, and the installation process begins automatically. The setup tool requests a Let's Encrypt SSL certificate by default.
You can run ./discourse-setup again if you need to change these settings.
To access your Discourse instance, use a web browser to navigate to your domain name, then follow the setup wizard to register your admin account.
Visit https://your_hostname/admin/upgrade, then click Upgrade to the Latest Version and follow the instructions.
Or, you can upgrade Discourse from the command line as follows:
Change directory to /var/discourse
$ cd /var/discourse
Get the latest version of Discourse
$ sudo git pull
Rebuild the Discourse app
$ sudo ./launcher rebuild app