Flarum is free and open-source forum software written in PHP, JavaScript, and TypeScript. Originally, Flarum is a merge of two different projects, the FluxBB, and esoTalk. Flarum is next-generation forum software designed to be minimal with high extensibility through extensions.

Flarum is a modern solution for Forum software, it’s fast, simple, and easy to use and install.

This tutorial will teach you how to install Flarum on the Debian 11 Bullseye. This tutorial also covers some basic configurations of LAMP Stack and the installation of PHP Composer for the Flarum web application.

Prerequisites

  • A Linux server Debian 11 Bullseye.
  • A root user or non-root user with root privileges.
  • A domain name pointed to the server.

Installing Apache2

The first step will be installing the Apache2 web server on your Debian system.

Check to update your repository package index using the following command.

sudo apt update

Install the Apache2 package using the below command.

sudo apt install apache2 -y

You will get the output:

<img alt="install apache2" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/1.png6261455ee35e1.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="311" loading="lazy" src="data:image/svg xml,” width=”750″>

After installing Apache2 packages, you can start the apache2 server and enable it.

sudo systemcttl start apache2

sudo systemctl enable apache2

The apache2 service is now running.

Now run the following command to open the HTTP and HTTPS ports on the firewall. In this example, the Debian server is running with the UFW firewall.

sudo ufw allow "WWW Full"

sudo ufw reload

Check and verify the UFW firewall rules.

sudo ufw status

You will get the following output.

<img alt="setup ufw firewall" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/2.png6261455f18ed7.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="339" loading="lazy" src="data:image/svg xml,” width=”599″>

Installing MariaDB Server

In the next step, you will be installing and configuring the MariaDB database on the Debian server.

Install MariaDB packages using the apt command below.

sudo apt install mariadb-server -y

You will get the following output:

<img alt="install mariadb" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/3.png6261455f3e34d.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="146" loading="lazy" src="data:image/svg xml,” width=”750″>

After the MariaDB installation is completed, start and enable the MariaDB service using the below command.

sudo systemctl start mariadb

sudo systemctl enable mariadb

You will get the output below:

<img alt="start mariadb" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/4.png6261455f670b1.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="111" loading="lazy" src="data:image/svg xml,” width=”750″>

The MariaDB service is running, now you will be setting up the MariaDB root password.

Run the mysql_secure_installation command below to start configuring the MariaDB server installation.

sudo mysql_secure_installation

Press ENTER to continue setting up the MariaDB server.

<img alt="setup password" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/5.png6261455f91885.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="246" loading="lazy" src="data:image/svg xml,” width=”670″>Advertisement

When asked to change the authentication method to unix_socket, type Y to confirm.

<img alt="authentication to unix_socket" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/6.png6261455fb8685.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="197" loading="lazy" src="data:image/svg xml,” width=”715″>

Now input Y to confirm and set up the root password for MariaDB. Then input the new password for your MariaDB root user and repeat the password.

<img alt="setup root password" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/7.png6261455fd7c41.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="177" loading="lazy" src="data:image/svg xml,” width=”714″>

Input Y to remove the default anonymous user from the MariaDB server.

<img alt="remove anonymous user" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/8.png6261456001fc5.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="174" loading="lazy" src="data:image/svg xml,” width=”687″>

Input Y again to disable remote login for the MariaDB root user.

<img alt="disable remote login root" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/9.png626145602983a.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="113" loading="lazy" src="data:image/svg xml,” width=”693″>

Input Y to remove the default database test from your MariaDB installation.

<img alt="remove database test" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/10.png6261456055cb1.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="191" loading="lazy" src="data:image/svg xml,” width=”683″>Advertisement

Lastly, input Y again to reload all tables privileges on the MariaDB server to apply new configurations.

<img alt="reload table privileges" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/11.png626145607c65a.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="259" loading="lazy" src="data:image/svg xml,” width=”721″>

Installing PHP Packages

Flarum is a web application written in PHP. So you will now be installing the PHP packages to your Debian server.

Install PHP packages with additional extensions for Flarum using the following command.

sudo apt install php php-common php-mysql libapache2-mod-php php-gd php-curl php-json php-xmlrpc php-intl php-bcmath php-zip php-apcu php-mbstring php-fileinfo php-xml php-soap php-tokenizer -y

You will get the output:

<img alt="install php" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/12.png62614560b1916.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="157" loading="lazy" src="data:image/svg xml,” width=”750″>

After PHP installation is completed, edit the php.ini config file using nano editor.

sudo nano /etc/php/7.4/apache2/php.ini

Change the default php.ini configuration according to follow configurations.

memory_limit = 512M

upload_max_file_size = 150M

max_execution_time = 600

date.timezone = Europe/Paris

Save the file by pressing CTRL X and confirm save by typing Y.

Now, to apply new changes to the php.ini configuration file, restart the Apache2 service using the below command.

sudo systemctl restart apache2

Installing Composer

To install Flarum, you will need the Composer installed on your Debian server. Composer is a dependency manager for PHP that allows you to manage libraries on your PHP application.

For nowadays, Composer is used on almost modern PHP frameworks such as Symfony and Laravel.

Download and verify the Composer installer.

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

php -r "if (hash_file('sha384', 'composer-setup.php') === '906a84df04cea2aa72f40b5f787e49f22d4c2f19492ac310e8cba5b96ac8b64115ac402c8cd292b8a03482574915d1a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

If you see the output message “Installer verified“, then the Composer installer is valid.

Now run the installer script to install Composer. When the installation is completed, remove the installer script.

php composer-setup.php

php -r "unlink('composer-setup.php');"

The binary file of Composer is now available on your working directory with the name composer.phar. Move the file to /usr/local/bin/composer so all users on the server will be able to execute the composer command.

sudo mv composer.phar /usr/local/bin/composer

<img alt="install composer" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/13.png62614560f1f5a.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="128" loading="lazy" src="data:image/svg xml,” width=”750″>

Next, verify the version of Composer that you just installed on your system using the following command.

sudo -u www-data composer --version

sudo -u www-data composer -v

You will get the following output.

<img alt="checking composer" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/14.png6261456148827.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="246" loading="lazy" src="data:image/svg xml,” width=”589″>

Create New Database and User for Flarum

Before you start jumping and installing Flarum, now you will need to create a new MariaDB database and user for the Flarum.

Login to the MariaDB shell as the root user using the below command.

sudo mysql -u root -p

Now create a new database flarumdb and user flarum with the password flarumdbpassword for the Flarum installation.

CREATE DATABASE flarumdb;

CREATE USER [email protected] IDENTIFIED BY 'flarumdbpassword';

GRANT ALL PRIVILEGES ON flarumdb.* to [email protected];

FLUSH PRIVILEGES;

After that, type exit to log out from the MariaDB shell or you can press CTRL D.

<img alt="create datavase" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/15.png626145619e017.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="447" loading="lazy" src="data:image/svg xml,” width=”750″>

Setup Project Directory Flarum

In this step, you will be downloading and installing the Flarum source using the PHP Composer.

First, create a new project directory /var/www/flarum and /var/www/.cache using the below command.

mkdir -p /var/www/{.cache,flarum}

The main Flarum project directory will be /var/www/flarum. And the directory /var/www/.cache will be used to store caches for the PHP Composer.

Next, change the ownership of both flarum and .cache directories to the www-data user. Also, you will need to give read and write permission to the www-data user.

sudo chown -R www-data:www-data /var/www/{.cache,flarum}

sudo chmod u rw /var/www/{.cache,flarum}

<img alt="create project directory" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/16.png626145621d4df.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="175" loading="lazy" src="data:image/svg xml,” width=”750″>

Now change your working directory to /var/www/flarum and install Flarum using the Composer command below.

cd /var/www/flarum

sudo -u www-data composer create-project flarum/flarum .

You will get the following output:

<img alt="download flarum" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/17.png626145626fd35.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="341" loading="lazy" src="data:image/svg xml,” width=”750″>

The Composer will install Flarum and all additional PHP dependencies needed for Flarum.

Once all Flarum is installed, you will see Flarum source code available at the /var/www/flarum directory. And the DocumentRoot directory for Flarum is available at the /var/www/flarum/public directory.

Setup Apache Virtual host

Before start accessing the Flarum installation, you will need to create a new Apache2 virtual host configuration for the Flarum.

Let’s start by enabling some Apache modules using the following command.

sudo a2enmod ssl rewrite headers

You will get the following output.

<img alt="enable modules" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/18.png62614562ae725.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="301" loading="lazy" src="data:image/svg xml,” width=”750″>

Next, create a new virtual host configuration file /etc/apache2/sites-available/flarum.conf using nano editor.

sudo nano /etc/apache2/sites-available/flarum.conf

Paste the following virtual host configuration. You will need to change some options below such as the Domain name and the path of SSL certificates.



    ServerName example.io

    Redirect permanent / https://example.io/



    ServerAdmin [email protected]

    DocumentRoot /var/www/flarum/public

    ServerName example.io

    Protocols h2 http/1.1

    SSLEngine On

    SSLCertificateFile /etc/letsencrypt/live/example.io/fullchain.pem

    SSLCertificateKeyFile /etc/letsencrypt/live/example.io/privkey.pem

    

          Options FollowSymlinks

          AllowOverride All

          Require all granted

    

     ErrorLog ${APACHE_LOG_DIR}/error.log

     CustomLog ${APACHE_LOG_DIR}/access.log combined

    

    

            RewriteEngine on

            RewriteBase /

            RewriteCond %{REQUEST_FILENAME} !-f

            RewriteRule ^(.*) index.php [PT,L]

   

Save the file by pressing the CTRL X button and entering Y to confirm.

Now, let’s activate the virtual host configuration flarum.conf using the below command. Then verify all Apache2 configurations.

sudo a2ensite flarum.conf

sudo apachectl configtest

If you see the output message Syntax OK, then all of your Apache2 configurations are valid.

Lastly, restart the Apache2 service using the below command to apply new changes on your Apache2 web server.

sudo systemctl restart apache2

<img alt="setup apache virtual host" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/19.png62614562eaeaa.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="274" loading="lazy" src="data:image/svg xml,” width=”750″>

Start Flarum Installation

To start the Flarum installation and configuration, you need to access your Flarum via the URL https://yourdomain.com/, and you should get the following page.

Input the details of your Flarum installation such as site title and database details. Then input the admin user and password for Flarum.

<img alt="install flarum" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/20.png6261456339f7c.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="661" loading="lazy" src="data:image/svg xml,” width=”750″>

Click Install Flarum to start and confirm the Flarum installation.

When the installation is completed, you will get the Welcome message from the Flarum as below.

<img alt="welcome to flarum" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/21.png62614563892f1.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="287" loading="lazy" src="data:image/svg xml,” width=”750″>

If you go to the Flarum administration settings, you will see the information below.

Flarum v1.2.1 is installed on the Debian 11 server with PHP 7.4 and the MariaDB 10.5.

<img alt="flarum administration settings" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/22.png62614563d2711.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="462" loading="lazy" src="data:image/svg xml,” width=”750″>

Conclusion

Congratulation! You have now successfully installed the Flarum web application on the latest Debian 11 Bullseye with the LAMP Stack. You can now start adding some extensions to extend your Flarum web application.