How to Install Flarum on Debian 12
Flarum is a free, open-source, and next-generation forum application that helps you to build your online discussion forum. Flarum looks and feels great out of the box. The user interface is streamlined so you can spend less time clicking and more time talking.
Pre-requisites :
-
A system with Debian 12 installed and running.
-
root
access to the system. - LAMP Stack installed and running, for this, you can refer to one of our guides on installing the LAMP Stack (Apache, MariaDB, and PHP).
Update the system.
apt update
apt upgrade
Create a Flarum Database
mysql
Create database and user with the below command.
Replace the password with a strong and secure password.
MariaDB [(none)]> CREATE DATABASE flarum;
MariaDB [(none)]> CREATE USER 'flarum'@'localhost' IDENTIFIED BY 'password';
Grant all the privileges to the flarum database using the below command,
MariaDB [(none)]> GRANT ALL PRIVILEGES ON flarum.* TO 'flarum'@'localhost';
Flush the privileges and exit,
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;
Install Composer
Install composer using below command,
apt install curl -y
curl -s https://getcomposer.org/installer | php
Output:
root@vps:~# curl -s https://getcomposer.org/installer | php
All settings correct for using Composer
Downloading...
Composer (version 2.5.8) successfully installed to: /root/composer.phar
Use it: php composer.phar
root@vps:~#
Move Composer binary file to the /usr/local/bin/
directory with the following command,
mv composer.phar /usr/local/bin/composer
Verify Composer version using below command,
composer -V
Output:
root@vps:~# composer -V
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Continue as root/super user [yes]? yes
Composer version 2.5.8 2023-06-09 17:13:21
root@vps:~#
Install Flarum
Need to create directory for Flarum inside Apache web directory,
mkdir /var/www/html/flarum
Download the latest version of Flarum using Composer in /var/www/html/flarum
directory,
cd /var/www/html/flarum
composer create-project flarum/flarum . --stability=beta
Install all PHP dependencies,
composer install
Change the ownership of Flarum to www-data and set permissions using below command,
chown -R www-data:www-data /var/www/html/flarum/
chmod -R 755 /var/www/html/flarum/
Configure Flarum with Apache.
Create Apache virtual host configuration file for host Flarum,
nano /etc/apache2/sites-available/flarum.conf
Add the following lines,
<VirtualHost *:80>
ServerAdmin flarum.domainhere.info
DocumentRoot /var/www/html/flarum/public
ServerName flarum.domainhere.info
DirectoryIndex index.php
<Directory /var/www/html/flarum/public/>
Options +FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Replace
flarum.domainhere.info
with actual domain name.
Enable the Flarum virtual host and Apache rewrite module using the below command,
a2ensite flarum
a2enmod rewrite
Restart Apache serving to apply the changes,
systemctl restart apache2
systemctl status apache2
Output:
root@vps:/var/www/html/flarum# systemctl status apache2
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; preset: enabled)
Active: active (running) since Thu 2023-06-15 21:07:31 UTC; 4s ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 17805 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 17810 (apache2)
Tasks: 6 (limit: 4652)
Memory: 16.2M
CPU: 289ms
CGroup: /system.slice/apache2.service
├─17810 /usr/sbin/apache2 -k start
├─17811 /usr/sbin/apache2 -k start
├─17812 /usr/sbin/apache2 -k start
├─17813 /usr/sbin/apache2 -k start
├─17814 /usr/sbin/apache2 -k start
└─17815 /usr/sbin/apache2 -k start
Secure Flarum with Let's Encrypt SSL
First, install the Certbot Let's Encrypt client using the below command,
apt-get install python3-certbot-apache -y
Run the below command to install Let's Encrypt SSL for Flarum Site,
certbot --apache -d flarum.domainhere.info
You will be asked to provide your email address and accept the terms,
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): Your_Email_Address
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for flarum.domainhere.info
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/flarum-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/flarum-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/flarum-le-ssl.conf
Choose whether or not to redirect HTTP traffic to HTTPS.
Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
Output:
Redirecting vhost in /etc/apache2/sites-enabled/flarum.conf to ssl vhost in /etc/apache2/sites-available/flarum-le-ssl.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://flarum.domainhere.info
You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=flarum.domainhere.info
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/flarum.domainhere.info/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/flarum.domainhere.info/privkey.pem
Your cert will expire on 2020-11-21. To obtain a new or tweaked
version of this certificate in the future, simply run certbot again
with the "certonly" option. To non-interactively renew *all* of
your certificates, run "certbot renew"
- Your account credentials have been saved in your Certbot
configuration directory at /etc/letsencrypt. You should make a
secure backup of this folder now. This configuration directory will
also contain certificates and private keys obtained by Certbot so
making regular backups of this folder is ideal.
- If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le
- We were unable to subscribe you the EFF mailing list because your
e-mail address appears to be invalid. You can try again later by
visiting https://act.eff.org.
Navigate your browser:
Replace flarum.domainhere.info with actual_domain_name.
https://cutomer-domain.here
Fill the database and user details,
Now, Install Flarum and you will see the dashboard,
Done.
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME
for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS