Set Up Flarum From Scratch

1/6/2018 webflarumlinuxtutorial

Befor you continue (opens new window)

# 1. Get a VPS from Linode/Vultr/whatever

# 2. Pick a linux distribution and make it running(I use CentOS 7).

# 3. Install Apache/MySQL/PHP 7.1

# Get yourself a non-root sudo user

adduser USERNAME
passwd USERNAME
usermod -aG wheel USERNAME
su USERNAME
1
2
3
4

# Install and configure Apache

Check this out (opens new window)

First install it.

sudo yum update
sudo yum -y install httpd
sudo systemctl enable httpd.service
1
2
3

Then create directory structure.

sudo mkdir /etc/httpd/sites-available
sudo mkdir /etc/httpd/sites-enabled
1
2

Open config file:

sudo vim /etc/httpd/conf/httpd.conf
1

Add this to the end of the file:

IncludeOptional sites-enabled/*.conf
1

# Install MySQL

CentOS 7 by default uses MariaDB rather than MySQL, but there's no difference using it.

Note: yum installs MariaDB 5.5 by default, which no longer satisfies flarum's requirements. See here (opens new window) for instructions on installing MariaDB 10.

sudo mysql_secure_installation
1

Then create a user and a database in MySQL for flarum.

# Install and configure PHP

I'm using php 7.1 here.

Take a look at this (opens new window)

First add needed yum repo:

sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
1
2

Install php

sudo yum install mod_php71w php71w-cli php71w-xml php71w-mbstring php71w-mysql php71w-gd
1

# 4. Install Flarum

# Create site directory

Name your site directory whatever you like, I'll just stick with flarum.

sudo mkdir /var/www/flarum
1

# Install composer

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

# Fetch flarum content

cd /var/www
sudo yum install unzip
sudo chown USERNAME:GROUPNAME flarum
cd flarum
composer create-project flarum/flarum . --stability=beta
1
2
3
4
5

# Adjust ownership and permissions

Change directory's ower to apache for apache to operate:

cd ..
sudo chown -R apache:apache flarum
1
2

# 5. Make it up and running

# Create virtual host in apache for flarum

Name configuration file whatever you like:

cd /etc/httpd/sites-available
sudo vim flarum.conf
1
2

Fill in content below(Don't forget the url rewrite block!):

<VirtualHost *:80>
    ServerName YOURDOMAIN
    ServerAlias ALIAS
    DocumentRoot /var/www/flarum/public
    ErrorLog /var/www/flarum/storage/logs/error.log
    CustomLog /var/www/flarum/storage/logs/requests.log combined

    <Directory "/var/www/flarum/public">
        DirectoryIndex index.php
        AllowOverride All
        allow from all
    </Directory>
</VirtualHost>
1
2
3
4
5
6
7
8
9
10
11
12
13

Make your config go live

sudo ln -s /etc/httpd/sites-available/flarum.conf /etc/httpd/sites-enabled/flarum.conf
1

# Configure firewalld and restart Apache server

sudo firewall-cmd --add-service=http --permanent && sudo firewall-cmd --add-service=https --permanent
sudo systemctl restart firewalld
sudo apachectl restart
1
2
3

# 6. Visit your flarum site and enjoy!

# Note:Wrote this down based on my memory, if there are any missing pieces, post a comment below 😃

Last Updated: 5/6/2021, 9:08:41 AM