Install Firely III on FreeNAS
| 4 minutes
Homelab FreeNAS FreeBSD Opensource Self Hosted How-To

During my time at iseek, a great colleague Angus Kelsey introduced me to a self-hosted budget management application Firefly III. I was impressed with the finish on the product and was happily surprised to find it was open source and could be self-hosted.

I’ve got a FreeNAS server running at home for private workloads and wanted to install Firefly III on this server. Can’t be that hard, I thought. A quick search online didn’t find a straight forward article on installing exactly what I needed to get up and running. So, here it is!

Disclaimer: For this post, I’ve included MySQL in the same jail as the application. This isn’t how you should work with containerised applications. What you SHOULD do is have a separate MySQL container/jail running and use it as a shared DB instance for multiple applications. Better yet, one DB instance for each application to account for version compatibilities. I’ll probably update this article to do such a thing, but at this point I was quite happy to get this up.

Disclaimer 2: I’m not an experienced Apache, MySQL or PHP administrator in the slightest.

Create the jail

FreeBSD has had ‘containers’ for quite a while only they’re referred to as “Jails”. Additionally, FreeNAS has supported running and managing Jails alongside the FreeNAS OS. We’re going to create a new jail on our FreeNAS server to host our FireFly III instance.

It’s quite easy to make a jail. You can use the CLI as outlined here or you can use the GUI. I suggest using the CLI as you’ll need to be there for the next steps.

Follow the steps in the preceeding link and get yourself logged into the jail.

FAMP Installation

To get Firefly III running, the documentation states we’ll need a LAMP stack or equivalent. As we’re on FreeBSD, we’ll need a FAMP stack.

SSH to the FreeNAS server, and open the console of the jail you created in the last section: iocage console <jailname>


Let’s install Apache 2.4:

  1. Run pkg install apache24
  2. Run sysrc apache24_enable=yes
  3. Use a text editor and open the Apache config file located here: /usr/local/etc/apache24/httpd.conf.
  4. Find the mod_rewrite setting and uncomment it. From #LoadModule rewrite_module modules/ to LoadModule rewrite_module modules/
  5. Run service apache24 start


Time to install MySQL:

  1. Run pkg install mysql80-server-8.0.16.
  2. Enable the service: sysrc mysql_enable=yes.
  3. Start the service: service mysql-server start.

You’ll want to run the MySQL Secure Installation script to provide you with some secure default configurations.

  1. Run mysql_secure_installation.
  2. Press Enter when prompted for an answer to keep the defaults suggested by the script.

Configure a user and database:

  1. Log in to MySQL: mysql -u root -p
  2. Enter the root password if you set one.
  3. In the MySQL shell, run the following code:
    1. CREATE USER 'firefly'@'localhost' IDENTIFIED BY 'firefly';. Creates a new user on the DB server called “firefly”.
    2. ALTER USER 'firefly'@'localhost' IDENTIFIED WITH mysql_native_password BY 'firefly';. Sets a password for the new user.
    3. GRANT ALL PRIVILEGES ON *.* TO 'firefly'@'localhost';.
    4. CREATE DATABASE fireflyiii;

Create the new database for Firefly:

  1. CREATE DATABASE fireflyiii;
  2. CREATE USER 'firefly'@'localhost' IDENTIFIED WITH mysql_native_password BY 'dbuserpassword';. Replace “dbuserpassword” with your preferred database user password.
  3. GRANT ALL PRIVILEGES ON firefly.* TO 'firefly'@'localhost';
  4. exit to leave the MySQL console.

PHP 7.2

The last of the package installs: PHP.

  1. pkg install mod_php72-7.2.21
  2. pkg install php72-mysqli-7.2.21
  3. cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
  4. rehash
  5. Using pkg install <packagename>, install the following packages:
    1. php72-bcmath-7.2.21
    2. php72-intl-7.2.21
    3. php72-curl-7.2.21
    4. php72-zip-7.2.21
    5. php72-gd-7.2.21
    6. php72-xml-7.2.21
    7. php72-mbstring-7.2.21
    8. php72-ldap-7.2.21
    9. php72-fileinfo-7.2.21
    10. php72-extensions-1.0
    11. php72-pdo_mysql-7.2.21
    12. php72-composer-1.8.6
  6. Let’s set some PHP configuration: vi /usr/local/etc/apache24/Includes/php.conf
<IfModule dir_module>
        DirectoryIndex index.php index.htm
    <FilesMatch "\.php$">
        SetHandler application/x-httpd-php
    <FilesMatch "\.phps$">
        SetHandler application/x-httpd-php-source

That’s it for now, let’s move on.

Firefly III Install

  1. Change directory: cd /usr/local/www/apache24/data.
  2. Use Composer to pull down and build the Firefly application: composer create-project grumpydictator/firefly-iii --no-dev --prefer-dist firefly-iii
  3. chmod -R 775 firefly-iii/storage
  4. In the firefly-III directory you will find a .env file. Open this file using your favorite editor. You only really need to set your email address and the DB server details to get this working. Here are a few fields you’ll need to update:
    1. Update the admin email field.
    2. In the MySQL DB settings, update the hostname (to “localhost”), DB name, DB user and password.
  5. php artisan migrate:refresh --seed
  6. php artisan firefly-iii:upgrade-database
  7. php artisan passport:install
  8. Set the www user as the owner of the Firefly-III directory: chown -R www firefly-iii/

Configure Apache

If you followed along and left most of the defaults, there’s one more thing you’ll need to update. And that is the Apache httpd.conf file.

  1. Edit /usr/local/etc/apache24/httpd.conf.
  2. Find the “DocumentRoot” line and edit both instances of the following default values:
    1. From /usr/local/www/apache24/data to /usr/local/www/apache24/data/firefly-iii/public.
  3. Add the following line to the end of the file: Include /usr/local/etc/apache24/Includes/php.conf
  4. Restart Apache service apache24 restart.

So, assuming I haven’t left anything out and this is correct, you should be up and running with Firefly-III! Leave a comment if you’re having issues or questions.

About Stellios Williams
Senior Cloud Solutions Architect - Service Providers VMware
This is my personal tech related blog for anything private and public cloud - including homelabs! My postings are my own and don’t necessarily represent VMware’s positions, strategies or opinions. Any technical guidance or advice is given without warranty or consideration for your unique issues or circumstances.
comments powered by Disqus