How to Install Flarum on Void Linux

In this tutorial, we will go through the steps required to install Flarum on Void Linux. Flarum is a free, open-source forum software that is easy to use, fast, and modern. Void Linux is an independent Linux distribution that uses the musl libc library and the runit init system.

Prerequisites

Before we begin, make sure you have the following:

Step 1: Update the System

Update the system by running the following command:

sudo xbps-install -Suv

This command updates the package database and installs any available updates.

Step 2: Install Required Dependencies

Flarum requires certain dependencies to be installed on your system. Use the following command to install them:

sudo xbps-install php php-fpm php-pdo_mysql php-json php-xml php-mbstring mariadb mariadb-client mariadb-server nginx

This command installs PHP, the MySQL database server, the NGINX web server, and other required packages.

Step 3: Configure MariaDB

By default, MariaDB is installed with an anonymous user and an open root account. Secure your MariaDB by running the following command:

sudo mysql_secure_installation

This command sets a root password and deletes the anonymous user.

Step 4: Create a Database for Flarum

Create a database for Flarum by running the following command:

sudo mysql -u root -p

You will be prompted to enter the root password you set in the previous step. Once you've logged in, create a new database, user, and password for Flarum by running the following commands:

CREATE DATABASE flarumdb;
CREATE USER 'flarumuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON flarumdb.* TO 'flarumuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Make sure to replace flarumdb, flarumuser, and password with your own values.

Step 5: Install Composer

Composer is a dependency manager for PHP. Use the following commands to download and install Composer:

sudo xbps-install curl php-curl
cd /tmp
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

Step 6: Install Flarum

Download and install Flarum by running the following commands:

sudo mkdir /var/www/flarum
sudo chown -R nginx:nginx /var/www/flarum
cd /var/www/flarum
sudo -u nginx composer create-project flarum/flarum .

This command creates the directory /var/www/flarum and installs Flarum in that directory. It also sets the owner of the directory to the NGINX user.

Step 7: Configure NGINX

Configure NGINX to serve the Flarum files by creating a new server block:

sudo vi /etc/nginx/conf.d/flarum.conf

Add the following configuration:

server {
    listen 80;
    server_name example.com;
    root /var/www/flarum/public;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/run/php-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;      
    }
}

Replace example.com with your own domain name.

Once you have made the changes, save and close the file.

Restart NGINX by running the following command:

sudo service nginx restart

Step 8: Install Flarum

Finally, visit your domain name in your web browser to install Flarum. Flarum will guide you through the installation process, where you will need to enter the database information you created in step 4.

Congratulations! You have successfully installed Flarum on Void Linux.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!