Your own Forum? Sure Just Learn how to Install Flarum Forum on Ubuntu 20.04

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

Hello, friends. Have you ever thought about creating your own forum? Well, there are tools with which we can do it without many problems. So in this post, you will learn how to create your own forum and install Flarum Forum in Ubuntu 20.04.

Quickly and as an introduction, we can say that Flarum Forum is a tool created in PHP with which we can deploy our forum without too many issues.

Created with PHP and using open-source tools, we will have an efficient, fast and very dynamic way to create our forum. All this also being free without advertising or subscriptions, making it ideal for personal or educational projects.

So let’s install it, its dependencies are not difficult to fulfill.

Preparing the system for Flarum Forum on Ubuntu 20.04

The first thing we have to do is to update the system completely. To complete this, run this pair of commands.

sudo apt update
sudo apt upgrade

Now we need to install LAMP on Ubuntu 20.04 In this post, explaining the whole LAMP process is not the main goal, so we are just going to install it using the command.

sudo apt install apache2 php php-zip libapache2-mod-php php-mysql php-dom php-gf php-mbstring php-json php-curl php-tokenizer php-pdo php-pdo php-ctype mariadb-server

In this command, Apache, PHP, the required PHP modules as well as MariaDB will be installed.

After this, we also have to install other necessary packages such as curl.

sudo apt install curl unzip

With this, we can continue the installation process.

Preparing PHP for Flarum Forum

Before we continue, it is necessary to make some adjustments to the PHP configuration to ensure the smoothness of Flarum Forum.

So, open the configuration file:

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

And modify the following values:

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

Save changes. That’s enough for now.

Create a database for Flarum Forum

The next step is to create a new database and user so that the application can handle it properly.

If the MariaDB installation is new, then you have to define a new key for the root user using the mysql_secure_installation script.

sudo mysql_secure_installation

There, you will have to log in with an empty password by pressing Enter. Then, define the new password for the root user. Then answer And to all the configuration questions.

When you are done, you will be able to access the MariaDB console.

sudo mysql -u root -p

Now create the new database. Name it whatever you want.

CREATE DATABASE flarumdb;

Now a new user along with the password. You can change the username as well as the password to a stronger one.

CREATE USER 'user'@'localhost' IDENTIFIED BY 'pass';

Assign sufficient permissions to this user on the newly created database.

GRANT ALL PRIVILEGES ON flarumdb.* TO 'user'@'localhost';

Apply the changes:

FLUSH PRIVILEGES;

And exit the console.

exit;

Installing PHP Composer on Ubuntu 20.04

One of the best ways to install Flarum Forum is to do it through Composer. So, it is necessary to install PHP Composer before proceeding.

To complete this, thanks to the curl command, you can then download the installer.

sudo curl -s https://getcomposer.org/installer | php

Now move the generated file to the folder where the system executables are located.

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

Finally, check if the installation was successful by verifying the version of Composer.

composer -V

Install Flarum Forum on Ubuntu to create your own blog

First create the folder where the application files will be and then access it.

sudo mkdir /var/www/html/flarum
cd /var/www/html/flarum

Then, thanks to Composer, install Flarum Forum in Ubuntu 20.04

sudo composer create-project flarum/flarum . 
--stability=beta
sudo composer install
1.- Install Flarum Forum on Ubuntu 20.04
1.- Install Flarum Forum on Ubuntu 20.04

In order for Flarum Forum to run correctly, you have to make Apache the owner of the folder.

sudo chown -R www-data:www-data /var/www/html/flarum/

And give it appropriate permissions:

sudo chmod -R 755 /var/www/html/flarum/

Now create a new VirtualHost to better manage the website.

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

Add the following content

<VirtualHost *:80>
 DocumentRoot /var/www/html/flarum/public
 ServerName domain
 DirectoryIndex index.php
 <Directory /var/www/html/flarum/public/>
Options +FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
 </Directory>
 ErrorLog ${APACHE_LOG_DIR}/flarum-error.log
 CustomLog ${APACHE_LOG_DIR}/flarum-access.log combined
</VirtualHost>

Remember that here you have to modify the value of ServerName to your domain name.

Save the changes and close the text editor.

Enable the new site by running

sudo a2ensite flarum

Don’t forget the rewrite module

sudo a2enmod rewrite

To apply the changes, restart Apache.

sudo systemctl restart apache2

Completing the installation of Flarum Forum

Now, in your favorite web browser, visit your domain to complete the installation.

You will see the following screen where you have to define the title of your Forum. You will also need to enter the credentials for the database we created earlier.

2.- Flarum Forum configuration
2.- Flarum Forum configuration

And below the forum administrator user.

3.- Admin account on Flarum Forum
3.- Admin account on Flarum Forum

If everything went well, you will be redirected to your forum, where you can start administering it.

4.- Flarum Forum on Ubuntu 20.04
4.- Flarum Forum on Ubuntu 20.04

Enjoy it.

Conclusion

In this post, you learned how to create your own forum by installing Flarum Forum on an Ubuntu 20.04 server. I hope it will be useful to you at some point.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
Angelo
Angelo
I am Angelo. A systems engineer passionate about Linux and all open-source software. Although here I'm just another member of the family.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook