Self-Hosting a Lightweight Forum with Discourse or Flarum
Self-Hosting a Lightweight Forum with Discourse or Flarum
Introduction
Self-hosting a forum is a great way to build an online community while maintaining control over data and customization. Discourse and Flarum are two popular open-source forum platforms, each catering to different needs. This guide walks you through setting up either Discourse or Flarum on your server.
Step 1: Choosing Between Discourse and Flarum
-
Discourse: A feature-rich forum that requires Docker and PostgreSQL.
-
Flarum: A lightweight PHP-based forum using MySQL or MariaDB, ideal for minimal setups.
-
Choose based on your server resources and feature requirements.
Step 2: Setting Up Discourse
- Install Docker and dependencies:
sudo apt update && sudo apt install -y curl git docker.io
- Clone the Discourse repository:
git clone https://github.com/discourse/discourse_docker.git /var/discourse
- Navigate to the Discourse directory:
cd /var/discourse
- Run the setup script:
sudo ./discourse-setup
- Follow the prompts to configure domain, email settings, and database credentials.
- Once installed, start Discourse:
sudo ./launcher start app
Step 3: Setting Up Flarum
- Install required dependencies:
sudo apt update && sudo apt install -y nginx mariadb-server php php-cli php-fpm php-mbstring php-xml unzip
- Set up a MySQL database:
sudo mysql -u root -p
CREATE DATABASE flarum;
CREATE USER 'flarumuser'@'localhost' IDENTIFIED BY 'strongpassword';
GRANT ALL PRIVILEGES ON flarum.* TO 'flarumuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
- Install Composer (PHP dependency manager):
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
- Install Flarum:
composer create-project flarum/flarum /var/www/flarum
- Set file permissions:
sudo chown -R www-data:www-data /var/www/flarum
- Configure Nginx by creating a new site config at
/etc/nginx/sites-available/flarum
and adding:
server {
listen 80;
server_name yourdomain.com;
root /var/www/flarum/public;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
- Enable the site and restart Nginx:
sudo ln -s /etc/nginx/sites-available/flarum /etc/nginx/sites-enabled/
sudo systemctl restart nginx
Step 4: Configuring and Managing Your Forum
-
Access the forum in a web browser and complete the setup.
-
Create an administrator account and configure site settings.
-
Install plugins or extensions to enhance functionality.
-
Regularly update your forum software for security and performance.
Conclusion
By following this guide, you can self-host a lightweight forum using Discourse or Flarum, depending on your resource availability and requirements. This allows full control over user data and customizations, making it an ideal choice for building an online community.