Install and Configure Flarum on Ubuntu 22.04

This tutorial intends to teach you to Install and Configure Flarum Discussion Forum on Ubuntu 22.04. It is best for any site to use a discussion platform where the users can communicate with each other by sharing their ideas, experiences and etc. When it comes to this option, Flarum is a good solution for you.

Here are some features of Flarum:

  • Modern and responsive user interface
  • Rich Set of Extensions and plugins
  • User profiles and notifications
  • Search functionality
  • Multi-language support
  • Moderation tools
  • Security

This guide will teach you to set up Flarum on Ubuntu 22.04 step by step.


To install Flarum, you must have the following:

  • Apache (with mod_rewrite enabled)
  • PHP 7.3 or higher version
  • MariaDB 10.05 or higher version

For this purpose, you can visit this guide on How To Install LAMP Stack on Ubuntu 22.04.

  • A domain name that is pointed to your server’s IP address.

Steps To Install and Configure Flarum on Ubuntu 22.04

At this point, you can log in to your server as a non-root user with sudo privileges and follow the steps below.

Step 1 – Configure PHP for Flarum

At this point, you need to install some additional PHP extensions for Flarum on Ubuntu 22.04 with the following command:

sudo apt install php-{bcmath,xml,fpm,mysql,zip,intl,ldap,gd,cli,bz2,curl,mbstring,pgsql,opcache,soap,cgi}

Then, you need to make some configuration changes in the php.ini file. Open the following file with your favorite text editor, here we use the vi editor:

sudo vi /etc/php/8.1/apache2/php.ini

Find the following lines and make changes to them as shown below:

memory_limit = 256M
max_execution_time = 300
upload_max_filesize = 150M
allow_url_fopen = On
file_uploads = On

When you are done, save and close the file.

Step 2 – Create Flarum Database User

In this step, you need to log in to your MariaDB console and create a Flarum database and a database user. To log in to your MariaDB shell, run the following command:

sudo mariadb -u root -p

Enter your password and run the following command to create a Flarum database:

MariaDB [(none)]> CREATE DATABASE flarumdb;

Then, run the following command on Ubuntu 22.04 to create your Flarum database user and set a password for it:

MariaDB [(none)]> CREATE USER 'flarumuser'@'localhost' IDENTIFIED BY 'password';

Next, grant all the privileges to the database user by using the command below:

MariaDB [(none)]> GRANT ALL PRIVILEGES ON flarumdb.* TO 'flarumuser'@'localhost';

Finally, flush the privileges and exit from the MariaDB shell with the following commands:

MariaDB [(none)]> EXIT

Step 3 – Flarum Installation on Ubuntu 22.04

At this point, we will use the composer to download and install the Flarum discussion forum.

First, you need to create a working directory under the /var/www/html/ directory for Flarum. To do this, you can run the following command in your terminal:

 sudo mkdir /var/www/html/flarum

Then, switch to your Flarum directory:

cd /var/www/html/flarum

Now use the Composer to download and install the latest Flarum on Ubuntu 22.04:

sudo composer create-project flarum/flarum 

When you are done, you should get the following output:

 - Installing flarum/suspend (v1.7.0): Extracting archive
  - Installing flarum/tags (v1.7.1): Extracting archive
52 package suggestions were added by new dependencies, use `composer suggest` to see details.
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Generating autoload files
73 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
No security vulnerability advisories found

Next, use the following commands to set the correct permissions and ownership for the Flarum directory:

# sudo chown -R www-data:www-data /var/www/html/flarum/
# sudo chmod -R 755 /var/www/html/flarum/

Step 4 – Apache Configuration for Flarum

At this point, you need to configure your Apache to serve Flarum on Ubuntu 22.04.

First, you need to create an Apache virtual host file with your favorite text editor, here we use vi:

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

Add the following content to the file:

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/flarum

DirectoryIndex index.php

<Directory /var/www/html/flarum/>
Options +FollowSymLinks
AllowOverride All
Order allow,deny
allow from all


ErrorLog /var/log/apache2/flarum-error_log
CustomLog /var/log/apache2/flarum-access_log common


Note: Remember to change the server name with your domain name.

When you are done, save and close the file.

Then, you need to enable your Flarum site with the command below:

sudo a2ensite flarum

Also, you need to disable the default configuration file by using the following command:

sudo a2dissite 000-default.conf

Next, enable the rewrite module for Apache and restart it by using the following commands:

# sudo a2enmod rewrite
# sudo systemctl restart apache2

Step 5 – Configure Firewall

If you have a running UFW firewall, you need to open the following ports through the firewall:

# sudo ufw allow 80/tcp 
# sudo ufw allow 443/tcp

Reload the firewall to apply the new rules:

sudo ufw reload

Step 6 – Access Flarum Discussion Forum Web UI

At this point, you can finish your installation and access the Flarum web interface by typing your domain name in your web browser followed by /flarum/public:


You will see the following screen. Set up your forum by filling out your details and clicking Install Flarum:

Install Flarum

Finally, you will see the following screen and you can start your Flarum discussion on Ubuntu 22.04:

Flarum - start a discussion

Also, you can access the Flarum admin dashboard by clicking on the Profile icon and selecting the Administrator option.

Flarum admin dashboard

From the Flarum admin dashboard, you can control the commenting system, users, moderators, and other settings.

Step 7 (Optional) – Secure Flarum on Ubuntu 22.04 with Let’s Encrypt

At this point, you can configure the HTTPS for your site with Let’s Encrypt. To do this, you need to install the certbot Apache package with the command below:

sudo apt install python3-certbot-apache -y

Then, run the following command to create the free SSL certificates for your Flarum site:

sudo certbot --apache -d

Accept the terms and services and choose to redirect HTTP traffic to HTTPS. Finally, you should have SSL certificates.

Next, you need to edit the following Flarum config PHP file:

sudo vi /var/www/html/flarum/config.php

At the file, find the following URL line and append it as shown below:

'url' => '',

When you are done, save and close the file.

At this point, you can access your site through HTTPS:


That’s it you are done. For more information, you can visit the Flarum Docs page.


At this point, you have a great app for your discussion forums called Flarum on Ubuntu 22.04. As you saw, it is easy to install and use. Also, you have learned to secure your Flarum site with Let’s Encrypt.

Hope you enjoy it. For more guides and articles, you can check our orcacore blog page.



Please enter your comment!
Please enter your name here

Latest Articles


Most Popular