How to Install Flarum on Ubuntu Server Latest

In this tutorial, we will go through the steps required to install Flarum, a popular forum software, on Ubuntu Server. Flarum is built using PHP and the Laravel framework, so we will be installing PHP and other dependencies as well.

Prerequisites

Before starting with the installation of Flarum, make sure you have the following:

Step 1: Update and Upgrade Ubuntu Packages

We need to start by updating and upgrading the Ubuntu packages to their latest versions for security and stability reasons. Execute the following command:

sudo apt update && sudo apt upgrade -y

The update process should now start. After it is finished, we will proceed to the next step.

Step 2: Install Required Packages

Flarum requires a few dependencies that are not installed on a fresh Ubuntu Server installation. We will install them now. To install Apache, MySQL, PHP, and other required packages, run the following command:

sudo apt install apache2 mysql-server php php-mysql php-curl php-json php-gd php-mbstring php-dom unzip wget -y

The above command installs:

After executing the command, wait for the installations to finish.

Step 3: Configure MySQL

Secure the MySQL server by running:

sudo mysql_secure_installation

The script will prompt you for answering some questions. Follow the prompts to set the MySQL root password and answer other questions.

Step 4: Download Flarum

Download the latest stable release of Flarum from the official website. You can use wget to do this as shown below:

cd /tmp
wget https://flarum.org/download

The above command will download a compressed file named download in /tmp directory. We now need to extract the contents of the downloaded archive. We will use unzip command to extract the archive:

unzip download -d flarum

The above command will extract the contents of the archive in a new directory named flarum.

We will now move the extracted files to the Apache document root. The Apache document root is the location where the Apache webserver looks for files to serve over the web. Typically, this location is /var/www/html.

sudo mv flarum /var/www/html/

If you go to /var/www/html/, you will see a directory named flarum, which contains all the Flarum files that Apache will serve.

Step 5: Set File Permissions

We need to set some file permissions for Flarum. We will change the ownership of the flarum directory recursively to the Apache user, www-data, and set appropriate permissions.

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

Executing the above commands grants Apache the permission to read and write files in the Flarum directory.

Step 6: Create a Virtual Host

In this step, we will create a virtual host in Apache for the Flarum installation. A virtual host is used to separate different websites that are hosted on the same webserver.

First, we will create a new configuration file for the Flarum virtual host.

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

Add the following content to the file:

<VirtualHost *:80>
    ServerAdmin admin@example.com
    DocumentRoot /var/www/html/flarum/public

    <Directory /var/www/html/flarum/public>
        Options -Indexes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/flarum-error.log
    CustomLog ${APACHE_LOG_DIR}/flarum-access.log combined
</VirtualHost>

Save and close the file (Ctrl + X, then Y, then ENTER).

We have now created a new virtual host. We will now enable it and disable the default one.

sudo a2dissite 000-default.conf
sudo a2ensite flarum.conf

The above commands disable the default virtual host and enable the newly created Flarum virtual host.

We will now restart Apache for changes to take effect.

sudo systemctl restart apache2

Step 7: Install Flarum

We will now install Flarum. Execute the following commands.

cd /var/www/html/flarum
sudo php flarum install

The above command will start the Flarum installation process. You will be prompted with a series of questions. Answer the questions as required.

The installation script will set up the required database tables for Flarum and create an administrator account.

Step 8: Access Flarum

After successfully installing Flarum, you can access it at http://<your-server-IP>/ in your web browser.

You should now see the Flarum forum. Log in with the administrator account you created in the previous step.

Conclusion

In this tutorial, we have demonstrated how to install Flarum on the latest Ubuntu Server. Flarum is a great forum software that is easy to use and set up. You can configure it according to your needs and customize it with extensions and themes.

If you face any issues while following this tutorial, feel free to leave a comment below.

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!