How to Install Flarum on Ubuntu 20.04

Hello,

In this week’s feature highlight, we look at How to Install Flarum on Ubuntu 20.04

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.

Update the system.

apt update 

apt upgrade

Install LAMP Server

apt-get install apache2 mariadb-server php8.0 libapache2-mod-php8.0 php8.0-common php8.0-mbstring php8.0-xmlrpc php8.0-soap php8.0-mysql
php8.0-gd php8.0-xml php8.0-curl php8.0-cli php8.0-zip php8.0-tokenizer wget unzip curl git -y    

After installing all packages, edit the php.ini file for some tweak settings,

nano /etc/php/8.0/apache2/php.ini

Edit/Modify the following variables in php.ini as follows,

file_uploads = On
allow_url_fopen = On
memory_limit = 256M
upload_max_file_size = 150M
max_execution_time = 450

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,

curl -s https://getcomposer.org/installer | php

Output:

All settings correct for using Composer
Downloading...
Composer (version 1.10.10) successfully installed to: /root/composer.phar
Use it: php composer.phar

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:

Composer version 1.10.10 2020-08-03 11:35:19

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,

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

Replace (customer-domain.here) with (actual domain name).

Add the following lines,

<VirtualHost *:80>
 ServerAdmin customer-domain.here
 DocumentRoot /var/www/html/flarum/public
 ServerName customer-domain.here
 DirectoryIndex index.php
 <Directory /var/www/html/flarum/public/>
Options +FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
 </Directory>
</VirtualHost>

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:

? apache2.service - The Apache HTTP Server
 Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
 Active: active (running) since Sun 2020-08-23 09:57:11 UTC; 2min 44s ago
   Docs: https://httpd.apache.org/docs/2.4/
Main PID: 27164 (apache2)
  Tasks: 6 (limit: 2353)
 Memory: 12.3M
 CGroup: /system.slice/apache2.service
         ??27164 /usr/sbin/apache2 -k start
         ??27165 /usr/sbin/apache2 -k start
         ??27166 /usr/sbin/apache2 -k start
         ??27167 /usr/sbin/apache2 -k start
         ??27168 /usr/sbin/apache2 -k start
         ??27169 /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 customer-domain.here

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 customer-domain.here
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://customer-domain.here

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=customer-domain.here
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/customer-domain.here/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/customer-domain.here/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 customer-domain.here with actual_domain_name.

https://cutomer-domain.here
image

Done.

(Visited 72 times, 1 visits today)

Leave a Reply

Your email address will not be published.