How to Install Discourse on Ubuntu Server Latest
Discourse is a popular open-source discussion platform that is designed for modern web browsers. It is written in Ruby on Rails and JavaScript, and it uses PostgreSQL as the database. Here is a step-by-step guide on how to install Discourse on Ubuntu Server Latest.
Prerequisites
Before you start the installation process, make sure that you have the following prerequisites:
- Ubuntu Server Latest
- At least 2 GB of RAM
- At least 2 CPU cores
- At least 5 GB of free disk space
- A domain name or a server IP address
- A sudo user
Step 1: Update Ubuntu
Make sure that your Ubuntu system is up-to-date by running the following command:
sudo apt update && sudo apt upgrade -y
Step 2: Install Dependencies
Discourse requires a number of dependencies to work properly. You can install them by running the following commands:
sudo apt install -y curl git nginx docker.io postgresql postgresql-contrib redis-server imagemagick libjemalloc-dev
Step 3: Add a Discourse User
You need to create a separate user for Discourse to run as. Run the following command to create a new user with the username "discourse":
sudo adduser discourse
Step 4: Download Discourse
Next, you need to download the latest version of Discourse from their official website. You can do this by running the following command:
sudo -i -u discourse git clone https://github.com/discourse/discourse.git /var/www/discourse
Step 5: Configure Discourse
Now you need to configure Discourse for your server by editing the app.yml file. Run the following commands to copy the example configuration file to your Discourse directory:
cd /var/www/discourse/
sudo -u discourse cp containers/app.yml.example containers/app.yml
Next, open the app.yml file for editing:
sudo nano containers/app.yml
In this file, you'll need to provide some basic information about your server, including the domain name or IP address that you want to use for your forum. Once you have finished configuring the file, save and exit.
Step 6: Install and Run Discourse
To install and run Discourse, you need to execute the following commands:
./launcher bootstrap app
./launcher start app
This will start the process that configures and starts the containers for the Discourse application.
Step 7: Configure Firewall and Nginx
You need to configure the firewall to allow traffic to Discourse's default port, which is port 80. Run the following command to add a rule to the firewall:
sudo ufw allow http
Next, you need to configure Nginx to proxy traffic to Discourse. Run the following command to create a new Nginx configuration file:
sudo nano /etc/nginx/sites-available/discourse.conf
Then add the following lines to this file:
upstream discourse {
server 127.0.0.1:4000;
keepalive 256;
}
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://discourse;
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;
}
}
Replace example.com with your own domain name or IP address. Save and exit the file.
Now you need to enable the new configuration file and reload the Nginx service:
sudo ln -s /etc/nginx/sites-available/discourse.conf /etc/nginx/sites-enabled/discourse.conf
sudo systemctl restart nginx.service
Step 8: Access Discourse
Discourse is now up and running on your Ubuntu Server Latest. You can access it by navigating to your domain name or IP address in a web browser. You should see the Discourse setup page where you can configure your forum.
Conclusion
Discourse is a powerful discussion platform that can help you build an engaged community around your website. By following this tutorial, you have learned how to install and configure Discourse on your Ubuntu Server Latest.