In this guide, we will teach you how to install the Flarum forum software using a LAMP stack on Ubuntu 18.04.
Please note: This guide assumes that you have already created a separate user account that is sudo capable. This guide does NOT support installing and running as the ROOT user!
If you have not already done so, please visit: https://help.skysilk.com/support/solutions/articles/9000126208-how-to-create-new-users-and-grant-sudo-privileges-to-users-on-linux
We will be using a brand new Ubuntu 18.04 install for this tutorial so we're going to begin by updating the system.
sudo apt update && sudo apt upgrade -y
Next up, we will need a functional LAMP stack. (Linux, Apache, MySQL, PHP). We will also download composer and unzip which will be required later on in the guide.
sudo apt install apache2 mariadb-server php7.2 composer curl unzip -y
Once that completes, we will install the required PHP extensions. If you run into trouble installing any of the below, try modifying the package names to include 7.2 in them (e.g. php7.2-mbstring). Our system did not have trouble automatically selecting the right packages for all but php-dom, but your mileage may vary.
sudo apt install php-mbstring php-mysql php-json php-gd php7.2-dom php-fileinfo php-curl php-zip php-tokenizer -y
Moving forward we will need to set up our MySQL root account and then create our database plus its user.
sudo mysql_secure_installation
Follow the prompts and choose your settings based on your needs. We recommend setting a root user password.
Now we can continue with setting up our database, its user, and a secure password for the user. Once we're done, we will flush the privileges and exit MySQL. As we are using MariaDB, start by telling it that we are going to be using MySQL once we're logged in.
sudo mysql -u root -p
use mysql; CREATE DATABASE forums; CREATE USER 'forumsDBuser'@'localhost' IDENTIFIED BY 'your_super_secure_password'; GRANT ALL PRIVILEGES ON forums.* TO 'forumsDBuser'@'localhost'; FLUSH PRIVILEGES; exit;
From here, we will move into our website directory and install our project. We start by setting the file permissions for the html folder as well as ensuring the owner of this folder is both the www-data group and user.
sudo chmod -R 0775 /var/www/html sudo chown -R www-data:www-data /var/www/html
cd /var/www/html composer create-project flarum/flarum . --stability=beta
We need to enable the Apache Rewrite module.
sudo a2enmod rewrite
Then we will edit the default apache site conf file
sudo nano /etc/apache2/sites-enabled/000-default.conf
We want to modify the DocumentRoot to point to the newly generated public folder. This is to ensure that only files that are intended to be interacted with by the public are served.
DocumentRoot /var/www/html/public
sudo systemctl restart apache2
The rest of the setup is going to be smooth sailing from here. Open your web browser and navigate to your VPS IP address to finish the rest of the Flarum configuration.
If you get a message requesting you to set file permissions for Flarum folders, verify that the files inside your /var/www/html/ folder are owned by www-data:www-data
cd /var/www/html sudo chown -R www-data:www-data *
You should now be able to access this page
Go ahead and fill out this page and you're done. After a moment, you'll be brought to your new forums!
For more in-depth information about configuring and customizing Flarum, check out the official documentation over at https://docs.flarum.org/config
Join our Private Discord Chat to chat with, as well as find community assistance from other Verified SkySilk Users: https://invite.gg/SkySilk
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article