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.
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:
pkg install apache24
- Use a text editor and open the Apache config file located here:
- Find the mod_rewrite setting and uncomment it. From
#LoadModule rewrite_module modules/mod_rewrite.soto
LoadModule rewrite_module modules/mod_rewrite.so
service apache24 start
Time to install MySQL:
pkg install mysql80-server-8.0.16.
- Enable the service:
- 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.
- Press Enter when prompted for an answer to keep the defaults suggested by the script.
Configure a user and database:
- Log in to MySQL:
mysql -u root -p
- Enter the root password if you set one.
- In the MySQL shell, run the following code:
CREATE USER 'firefly'@'localhost' IDENTIFIED BY 'firefly';. Creates a new user on the DB server called “firefly”.
ALTER USER 'firefly'@'localhost' IDENTIFIED WITH mysql_native_password BY 'firefly';. Sets a password for the new user.
GRANT ALL PRIVILEGES ON *.* TO 'firefly'@'localhost';.
CREATE DATABASE fireflyiii;
Create the new database for Firefly:
CREATE DATABASE fireflyiii;
CREATE USER 'firefly'@'localhost' IDENTIFIED WITH mysql_native_password BY 'dbuserpassword';. Replace “dbuserpassword” with your preferred database user password.
GRANT ALL PRIVILEGES ON firefly.* TO 'firefly'@'localhost';
exitto leave the MySQL console.
The last of the package installs: PHP.
pkg install mod_php72-7.2.21
pkg install php72-mysqli-7.2.21
cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
pkg install <packagename>, install the following packages:
- Let's set some PHP configuration:
<IfModule dir_module> DirectoryIndex index.php index.htm <FilesMatch "\.php$"> SetHandler application/x-httpd-php </FilesMatch> <FilesMatch "\.phps$"> SetHandler application/x-httpd-php-source </FilesMatch> </IfModule>
That's it for now, let's move on.
Firefly III Install
- Change directory:
- Use Composer to pull down and build the Firefly application:
composer create-project grumpydictator/firefly-iii --no-dev --prefer-dist firefly-iii 126.96.36.199
chmod -R 775 firefly-iii/storage
- 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:
- Update the admin email field.
- In the MySQL DB settings, update the hostname (to “localhost”), DB name, DB user and password.
php artisan migrate:refresh --seed
php artisan firefly-iii:upgrade-database
php artisan passport:install
- Set the
wwwuser as the owner of the Firefly-III directory:
chown -R www firefly-iii/
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.
- Find the “DocumentRoot” line and edit both instances of the following default values:
- Add the following line to the end of the file:
- 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.