Install Flarum 1.0 on OpenBSD

The following tools was used for this project

Install dependencies. See Running WordPress on OpenBSD 6.6 With OpenBSD's HTTPD

pkg_add php php-curl php-mysqli php-zip php-pdo_mysql php-gd
cp /etc/php-7.3.sample/* /etc/php-7.3/.

See pkg-readme for general info about PHP.

Add PHP package manager and upgrade it to 2.x

pkg_add composer
composer -V
composer self-update --2

Enable extensions (if not already done)

ln -sf /etc/php-7.3.sample/gd.ini /etc/php-7.3/
ln -sf /etc/php-7.3.sample/pdo_mysql.ini /etc/php-7.3/

Check which extentions are enabled

php -m

Install Flarum 1.0. See Flarum: Installation

cd path/to/root
mkdir flarum
cd flarum
composer create-project flarum/flarum .

Check flarum version

php flarum info

Setup database

# mysql -u root -p
Enter password: 
> CREATE DATABASE flarum;
Query OK, 1 row affected (0.004 sec)
> GRANT ALL PRIVILEGES ON flarum.* TO 'flarumadmin'@'localhost' IDENTIFIED BY 'insideforum';
Query OK, 0 rows affected (0.013 sec)
> exit

Setup PHP FastCGI Server (PHP FPM). FPM comes part of the PHP package. See pkg-readme.

Start it and enable it to start at boot.

rcctl start php73_fpm
rcctl enable php73_fpm

Edit/check /etc/php-fpm.conf if needed. Default should be ok. Check log /var/www/logs/php-fpm.log.

Most important settings is to setup listen interface.

Either a TCP socket interface may be used.

; Alternative TCP socket to listen on
listen = 0.0.0.0:3015

Or a UNIX socket

; Alternative local UNIX socket to listen on
listen = /var/www/run/php-fpm.sock

Note that NGINX configuration fastcgi_pass param must be adapted accordingly.

If service fails to start us following to track errors.

rcctl -d start php73_fpm 

Setup NGINX as front end. Add the following example server block.

server {
    listen       80;
    server_name  flarum.ideell.se;
    index        index.php index.html index.htm;

    # NGINX is run in chroot under /var/www as well as PHP-FPM
    root         /var/www/pages/rails/flarum/public;

    location ~ [^/]\.php(/|$) {

        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        if (!-f $document_root$fastcgi_script_name) {
            return 404;
        }
        # Mitigate https://httpoxy.org/ vulnerabilities
        fastcgi_param HTTP_PROXY "";

        # Change in /etc/pfp-fpm.conf if you want to change to TCP port
        # fastcgi_pass 127.0.0.1:3015;

        # Note file is specified from within chroot
        fastcgi_pass unix:/run/php-fpm.sock;

        fastcgi_index index.php;
        include fastcgi_params;

        # chroot conf
        fastcgi_param  SCRIPT_FILENAME     $document_root$fastcgi_script_name;
        fastcgi_param  DOCUMENT_ROOT       /pages/rails/flarum/public;

        # non chroot configuration of PHP-FPM while nginx still in chroot
        # fastcgi_param  SCRIPT_FILENAME     /var/www$document_root$fastcgi_script_name;
        # fastcgi_param  DOCUMENT_ROOT       /var/www/pages/rails/flarum/public;
    }

    include /var/www/pages/rails/flarum/.nginx.conf;
}

Restart NGINX

nginx -t
rcctl restart nginx

Test to access site via browser. If you have problems add a test PHP script.

cat /var/www/pages/rails/flarum/public/test.php
<?php var_export($_SERVER)?>

When starting flarum site for the first time it will asks for general settings like database access parameters.

Note prefix that has to be flrm_. Also url is important if you change root domain for the host.

Force password change of user

By directly accessing the database

Get the current hash of the password

select password from flrm_users where email = 'user@domain.com';
=> $2y$10$v8rUFHQomJA1NZlkveiZpeoD57SNTUR6PcJ/i05g.6yqS8sRZL5QG

Generate a new BCrypt password e.g. via (Bcrypt-Generator.com)[https://bcrypt-generator.com/].

update flrm_users set password = '$2y$12$/mIxmAsbUV/t4W.gdKfyIuGA31CsH8qzfHgwOlZ7yN1fY39vKuRhG' where email = 'user@domain.com';

Transfer site between servers

If you want to transfer an existing site from another server.

Dump original databse

mysqldump -u'flarumadmin' -p'insideforum' flarum > flarum_pre10.sql

Restore it on new database

mysql -u'flarumadmin' -p'insideforum' flarum < flarum_pre10.sql

Selectively move assets from original to target server

cp -R assets_hk/fonts assets

Migrate database and clear cache before starting up

php flarum migrate
php flarum cache:clear

Internationalization

To support Swedish I installed the following extension.

https://discuss.flarum.org/d/5615-swedish-language-extension

Install it with composer and change default language to Swedish under Basics admin settings.

composer require nlssn/flarum-ext-swedish

References