You want to create an awesome Forum Discussion platform?. Flarum is the next-generation forum software that makes online discussion fun. It’s simple, fast, and free with all the features you need to run a successful community (Flarum GitHub Page). Though still in Beta state, it is designed to be:
- Fast and simple. No clutter, no bloat, no complex dependencies. Flarum is built with PHP so it’s quick and easy to deploy. The interface is powered by Mithril, a performant JavaScript framework with a tiny footprint.
- Beautiful and responsive. This is forum software for humans. Flarum is carefully designed to be consistent and intuitive across platforms, out-of-the-box.
- Powerful and extensible. Customize, extend, and integrate Flarum to suit your community. Flarum’s architecture is amazingly flexible, with a powerful Extension API.
“When the solution is simple, God is answering.”
― Albert Einstein
Server Requirements
Before you install Flarum, it’s important to check that your server meets the following requirements. To run Flarum, you will need:
- Apache (with mod_rewrite enabled) or Nginx
- PHP 7.2.9+ with the following extensions: curl, dom, gd, json, mbstring, openssl, pdo_mysql, tokenizer, zip
- MySQL 5.6+ or MariaDB 10.0.5+
- SSH (command-line) access to run Composer
Step 1: Update and install essential tools
Once in the terminal of your fresh Ubuntu server, update it and install esential tools we shall use in our installation process
sudo apt update && sudo apt upgrade
sudo apt install vim git unzip curl -y
Step 2: Install and setup database
We are going to use MariaDB for this setup.
curl -LsS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash -s --
sudo apt update
sudo apt install mariadb-server mariadb-client
After you have the database installed, the next step is to create a database and user for Mautic. Let us therefore go ahead and get this done as shown below. You are free to name your database and user differently and ensure you use a safe password.
$ sudo mysql -u root -p
CREATE DATABASE flarumdb;
CREATE USER 'flarumuser'@'localhost' IDENTIFIED BY 'StrongPassword';
GRANT ALL PRIVILEGES ON flarumdb . * TO 'flarumuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Step 3: Install web server and PHP
Flarum requires a webserver that will serve its pages. Here, you have the liberty to choose either Apache or Nginx. We shall use Nginx in this guide. Additionally, Flarum requires PHP and therefore we will have to set it up as well.
We have a complete guide that covers the installation of Nginx and PHP-FPM on Ubuntu. Kindly follow it then proceed to the next step.
Add recommended PHP Settings
Open up your php-fpm ini file and add/edit the details shown below. They include Timezone, and memory limit settings. Add your date.timezone and change memory_limit to 512MB.
$ sudo vim /etc/php/*/fpm/php.ini
memory_limit = 512M
[Date]
date.timezone = Africa/Nairobi
Install composer
Composer is a brilliant tool that installs PHP dependencies that a project requires. We shall use its amazing features to install the dependencies that Flarum requires. Do the following to setup composer
cd ~
curl -sS https://getcomposer.org/installer -o composer-setup.php
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
Test if composer is successfully installed by running the composer command
$ composer -V
Composer version 2.5.5 2023-03-21 11:50:05
Step 4: Fetch Flarum’s files and setup Nginx
We shall create a new directory (root) that Flarum’s files will reside as well as read and served by the webserver of our choice. You can create a different one according to your needs and design.
sudo mkdir /var/www/html/discussion/ && cd /var/www/html/discussion/
sudo composer create-project flarum/flarum . --stability=beta
The above command might take some time to complete as all the dependencies need to be retrieved and installed. Once everything is done, Flarum files will be dropped inside the current folder and you will notice a public directory inside. This is the root directory and holds all the files to be served by Nginx in this example.
Configure Nginx
We have to make a few changes to the Nginx configuration defaults by adding the details we need for Flarum. Change into sites-enabled, back up the default file and create a new one with new configurations.
cd /etc/nginx/sites-enabled/
sudo mv default /tmp
Create a new file and add the details shown below. If you have an FQDN, replace example.com with it.
$ sudo vim /etc/nginx/sites-enabled/flarum.conf
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name example.com;
root /var/www/html/discussion/public;
index index.html index.htm index.php;
location / {
try_files $uri /index.php$is_args$args;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php/php-fpm.sock;
fastcgi_index index.php;
fastcgi_read_timeout 240;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_split_path_info ^(.+.php)(/.+)$;
}
}
Change Flarum’s files permissions
In order for Nginx to read the files, we have to grant it the rights and the right permissions. Issue the commands below to get that done.
sudo chown -R www-data:www-data /var/www/html/discussion/
sudo chmod -R 755 /var/www/html/discussion/
sudo systemctl restart nginx php*-fpm.service
Step 5: Access Flarum Web Interface
To complete setting up Flarum, point your browser to the IP or domain name of the webserver serving the files. http://[ip-or-domain-name]. You should get a page like below.
It is a form asking you to fill in all the database details including adding an administrative account. Fill it in nicely then click on “Install Flarum“. Give it a few seconds and you will be ushered into the dashboard.
The main page looks like the screenshot below
Create Sample Discussion
To create a sample discussion, click on “Start a Discussion” as above and a pop up will appear at the bottom center of the page asking you for the details of the Discussion. Fill it in then click on “Post Discussion“. A pop up prompting you to choose a tag will appear. Since we haven’t created any tags yet, choose the default “General” one and click “OK“
Once the discussion has been submitted, the people allowed in the discussion will be able to reply and contribute.
Create a Tag
To create custom tags together with other administrative tasks, click on the admin user icon on the top right and a drop-down menu will appear. As you may guess, click on “Administration“. That will lead you to the admin page where you can add Tags, Extensions, change appearance, Configure Email, and much more. Feel free to play around with the features therein.
To create a tag, simply click on “Tags“, then “Create Tag“.
A pop up as shown below will appear where you can freely add a custom tag you might use in one of your Discussions in the future. Click “Save Changes” once you are done.
Explore other features whilst logged in as you get acquainted with Flarum. For example, below you can see the many extensions that can be integrated with your Flarum instance to make it even better. Much more awaits you as you venture into using this amazing discussion tool.
Check out more about Flarum on:
Final Words
There we have it now guys. Our Discussion platform is up and ready for use. It has been a winderful ride and we hope you enjoyed it. We appreciate your visitation and hope Flarum will serve you well.
Other gripping guides:
Host WordPress website with Caddy Web Server
How To host Multiple Sites on Nginx with same Domain (FQDN)
How To Install PHP Composer on CentOS 8 / RHEL 8
Install PHP Composer on Cpanel