Install Flarum Forum Discussion Site on Ubuntu 20.04

To
You can download this article in PDF format to support us through the following link.

Download the guide in PDF format

turn off
To

To
To

Flarum is the next generation forum software that makes online discussions interesting. It is simple, fast and free, and provides all the features needed to build a successful community (Flarum GitHub page). Although still in Beta status, it is designed as:

  • Quick and easy. There is no confusion, no expansion, no complicated dependencies. Flarum is built using PHP, so it can be deployed quickly and easily. This interface is supported by Mithril (a small high-performance JavaScript framework).
  • Beautiful and responsive. This is human forum software. Flarum has been carefully designed to be consistent and intuitive across various platforms.
  • Powerful and scalable. Customize, extend and integrate Flarum to suit your community. Flarum’s architecture is very flexible and has a powerful extension API.

“When the solution is simple, God will answer.” Albert Einstein

Server requirements

Before installing Flarum, be sure to check whether your server meets the following requirements. To run Flarum, you will need:

  • Apache (mod_rewrite enabled) or Nginx
  • PHP 7.2.9+ has the following extensions: curl, dom, gd, json, mbstring, openssl, pdo_mysql, tokenizer, zip
  • MySQL 5.6 or above or MariaDB 10.0.5 or above
  • SSH (command line) access to run Composer

Step 1: Update and install basic tools

After entering the terminal of the new Ubuntu server, update it and install the basic tools that will be used during the installation process

sudo apt update && sudo apt upgrade
sudo apt install vim git unzip curl -y

Step 2: Install and set up the database

We will use MariaDB for this setup. Fortunately, we already have a detailed guide to install MariaDB 10.5. Check out how to install MariaDB 10.5 on Ubuntu 20.04

After installing the database, the next step is to create a database and user for Mautic. So let’s proceed with this operation as shown below. You can use different names to name the database and users at will, and make sure to use secure passwords.

$ mysql -u root -p
Enter password: 

MariaDB [(none)]> CREATE DATABASE flarumdb;
MariaDB [(none)]> CREATE USER 'flarumuser'@'localhost' IDENTIFIED BY 'StrongPassword';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON flarumdb . * TO 'flarumuser'@'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit;

Step 3: Install and configure the web server and PHP

Flarum needs a web server that will serve its pages. Here, you can choose Apache or Nginx. We will use Nginx in this guide. In addition, Flarum requires PHP, so we must also set it up.

We have a complete guide covering the installation of Nginx and PHP-FPM on Ubuntu 20.04. Please follow it and proceed to the next step.

Add recommended PHP settings

Open your php-fpm ini file and add/edit the details shown below. They include time zone and memory limit settings. Add your date.timezone and change the memory_limit to 512MB.

$ sudo vim /etc/php/7.4/fpm/php.ini

memory_limit = 512M

[Date]
date.timezone = Africa/Nairobi

Install composer

Composer is an excellent tool that installs the PHP dependencies required by the project. We will use its amazing features to install the dependencies required by Flarum. Do the following to set up the 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 whether composer is successfully installed by running the composer command

$ composer -V
Composer version 1.10.9 2020-07-16 12:57:00

Step 4: Get Flarum files and configure Nginx

We will create a new directory (root directory) for the web server of our choice to reside, read and serve Flarum files. You can create a different object 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

Creating a "flarum/flarum" project at "./"
Installing flarum/flarum (v0.1.0-beta.13)
  - Installing flarum/flarum (v0.1.0-beta.13): Downloading (100%)

As all dependencies need to be retrieved and installed, the above command may take some time to complete. After all operations are completed, the Flarum file will be dragged and dropped into the current folder, and you will notice that there is a public directory in it. This is the root directory. In this example, it contains all the files that Nginx will provide.

Configure Nginx

We have to make some changes to the Nginx configuration defaults by adding the details required by Flarum. Change to enable the site, back up the default file and create a new file with the new configuration.

cd /etc/nginx/sites-enabled/
sudo mv default /tmp

Create a new file and add the details as shown below. If you have an FQDN, replace it with example.com.

$ 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/php7.4-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 file permissions

In order for Nginx to read the file, we must grant permissions to it. Issue the following commands to complete the task.

sudo chown -R www-data:www-data /var/www/html/discussion/
sudo chmod -R 755 /var/www/html/discussion/
sudo systemctl restart nginx php7.4-fpm

Step 5: Visit Flarum Web interface on Ubuntu 20.04

To complete the setup of Flarum, point your browser to the IP or domain name of the web server that provides the file. http: //[ip-or-domain-name]. You should get the following page.

It is a form that requires you to fill in all database details, including adding an administrative account. Fill it out nicely and click “Install Flarum“. Give it a few seconds and you will be taken to the dashboard.

Install Flarum Forum Discussion Site on Ubuntu 20.04

The homepage looks like the screenshot below

Install Flarum Forum Discussion Site on Ubuntu 20.04

Create a sample discussion

To create a sample discussion, click “Start discussion“, then a pop-up window will be displayed at the bottom center of the page, asking you to provide detailed information for the discussion. Fill in and click “After discussion“. A pop-up window will appear prompting you to select a label. Since we have not created any labels yet, please select the default “general“then click”it is good

Install Flarum Forum Discussion Site on Ubuntu 20.04

Install Flarum Forum Discussion Site on Ubuntu 20.04

After submitting the discussion, the people allowed in the discussion will be able to reply and contribute.

Install Flarum Forum Discussion Site on Ubuntu 20.04

Create label

To create a custom label along with other administrative tasks, click the admin user icon in the upper right corner, and a drop-down menu will appear. As you might guess, click “administrative“. This will take you to the management page, where you can add tags, extensions, change the appearance, configure email, etc. Feel free to use the functions.

Install Flarum Forum Discussion Site on Ubuntu 20.04

To create a label, just click “label“And then”Create label“.

Install Flarum Forum Discussion Site on Ubuntu 20.04

A pop-up window as shown below appears, in which you can freely add a custom tag that you may use in your “Discussion” in the future. Click “save Changesafter finishing.

Install Flarum Forum Discussion Site on Ubuntu 20.04

Get familiar with Flarum while browsing other functions. For example, below you can see that many extensions can be integrated with Flarum instances to make it better. When you take the plunge with this amazing discussion tool, there is more waiting for you.

Install Flarum Forum Discussion Site on Ubuntu 20.04

Learn more about Flarum:

Final words

There, we have it now. Our discussion platform is activated and ready to use. This is a windy journey and we hope you enjoy it. We thank you for coming, and hope Flarum can serve you.

Other hand guides:

Use Caddy Web Server to host your WordPress website

How to host multiple sites on the same domain (FQDN) on Nginx

How to install PHP Composer on CentOS 8 / RHEL 8

Install PHP Composer on Cpanel

To
You can download this article in PDF format to support us through the following link.

Download the guide in PDF format

turn off
To

To
To

Sidebar