Firefly III Personal Finance Manager

To optimize personal finances, it is often recommended to record and analyze your, at least basic, expenses and incomes, and plan a budget. For this, many applications have been created on various platforms. Many of them are usually paid or require a paid subscription to unlock advanced features – CoinKeeper, Drebedengi, Zen-Money, Alzex Finance, etc., on the other hand, home finances can be maintained in Google spreadsheets or in Excel, but the last two options are not especially convenient.

Some of the listed applications work only on a smartphone, some have a version for a PC or a web version. Many support a large number of accounts and categories of expenses / incomes, have a budget planning function. Some of them support multiple users. You have to pay for most of the advanced features – either one-time or periodically.

I have used some of the listed applications. So I used the Drebedengi application for android and its web version for several years. Satisfied with everything, except that for the use of additional. functions, including synchronization work and the number of records, you must pay an annual subscription. In addition, the database is stored in an incomprehensible place, although there is little benefit from this data to an outsider, but still. I used the Alzex Finance application – also a very convenient application, there is a version for PC. One of the interesting features of the mobile version is the import of JSON data from the tax application “Check Checks”, reading SMS from banks. Periodically, the application encountered errors when synchronizing via Google Drive.

Looking for the best app I came across Firefly III – an open source personal finance manager with Russian language support, devoid of ads, subscriptions and any tracking, available for installation on its server (there are no separate applications for a smartphone or PC). A weak cloud server, a virtual machine, a Raspberry Pi can act as a server – everything on which you can install the LAMP stack or its analogues. I have not seen a fully working installation instruction in Russian, so I decided to write my own. So, let’s begin.

The server is a virtual machine on the home NAS. Its configuration is minimal – 1 processor, 1 GB of RAM, the hard drive is allocated with a margin of 30 GB. It will most likely work on servers with a weaker configuration. The server has Ubuntu Server 20.04 installed without any pre-installed applications. Installation and configuration of Firefly III is done through the terminal. In this tutorial, I will describe the installation of a web server based on nginx, mariaDB, php and the initial setup of Firefly III.

First you need to update the packages on the server and install git, nginx (you can also use Apache if you wish), curl:

sudo apt update && sudo apt upgrade
sudo apt install git nginx curl -y

For Firefly III to work correctly, it is recommended to install php-fpm at least version 8 and a number of modules:

sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install -y php8.0 php8.0-{cli,zip,gd,fpm,common,mysql,zip,mbstring,curl,xml,bcmath,imap,ldap,intl}

After installing php, check if it is successful:

sudo systemctl status php8.0-fpm

The answer should be similar to this:

 php8.0-fpm.service - The PHP 8.0 FastCGI Process Manager
     Loaded: loaded (/lib/systemd/system/php8.0-fpm.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2022-02-22 13:08:53 UTC; 6h ago
       Docs: man:php-fpm8.0(8)
    Process: 20421 ExecStartPost=/usr/lib/php/php-fpm-socket-helper install /run/php/php-fpm.sock />
   Main PID: 20415 (php-fpm8.0)
     Status: "Processes active: 0, idle: 3, Requests: 728, slow: 0, Traffic: 0req/sec"
      Tasks: 4 (limit: 1062)
     Memory: 79.0M
     CGroup: /system.slice/php8.0-fpm.service
             ├─20415 php-fpm: master process (/etc/php/8.0/fpm/php-fpm.conf)
             ├─20624 php-fpm: pool www
             ├─20626 php-fpm: pool www
             └─20631 php-fpm: pool www

We will slightly adjust the basic php settings by increasing the memory limit and specifying the time zone, for this we will edit the configuration file:

sudo nano /etc/php/8.0/fpm/php.ini

You need to find the “line memory_limit = 128M” and increase the value to 512M, and change the date.timezone variable according to your location (you can check the correct spelling of the zone in google, for Moscow – Europe /Moscow). Use ctrl + w to search for a line, ctrl + o to save changes, ctrl + x to exit the text editor.

The next step is to add the nginx configuration:

sudo nano /etc/nginx/sites-enabled/firefly.conf

In the empty window that opens, paste the following code, replacing server_name with the name of your server if necessary:

server {
        listen       8080 default_server;
        listen       [::]:8080 default_server;
        server_name  example.com;
        root         /var/www/html/firefly-iii/public;
        index index.html index.htm index.php;

        location / {
                try_files $uri /index.php$is_args$args;
        }

        location ~ .php$ {
        fastcgi_pass unix:/run/php/php8.0-fpm.sock;
        fastcgi_index index.php;
        fastcgi_read_timeout 240;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_split_path_info ^(.+.php)(/.+)$;
        }
    }

The next step is to install the MariaDB database server. To install a more recent version on Ubuntu 20.04, add the repository:

sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
sudo add-apt-repository 'deb [arch=amd64] http://mariadb.mirror.globo.tech/repo/10.5/ubuntu focal main'

Let’s upgrade and install MariaDB:

sudo apt update
sudo apt install mariadb-server mariadb-client
sudo mysql_secure_installation

After the third command, the installer will ask a series of questions – you will need to change the root password (initially, when prompted for a password, press Enter, since the password is not set), we must remember the new password. We answer yes to questions about deleting anonymous users and test databases, banning remote access, etc.

Once the installation and configuration of the database server is complete, you need to create a database user and database for Firefly III. We start the client with the command:

sudo mysql -u root -p

When prompted for a password, enter the previously set password. And execute the following commands:

CREATE DATABASE firefly_database;
CREATE USER 'fireflyuser'@'localhost' IDENTIFIED BY 'StrongPassword';
GRANT ALL PRIVILEGES ON firefly_database. * TO 'fireflyuser'@'localhost';
FLUSH PRIVILEGES;
exit;

In the first line we create the database firefly_database (you can set your own database name, username and password), the second line – create a database user and write the password for it in quotes, in the third line we provide the user with access to the previously created database, then update the rights and exit . Note that each line ends with ;. After each command, the server reports its successful execution.

To further install Firefly III, install PHP Composer:

cd ~
curl -sS https://getcomposer.org/installer -o composer-setup.php
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer

To test the installation, check the version of PHP Composer

composer -V

Go to the main directory of the web server and run the installation of Firefly III. Firefly III is constantly updated, the current version is 5.6.14, the current one can be found here . In the second command, you need to change the version number to the current one:

cd /var/www/html/
sudo composer create-project grumpydictator/firefly-iii --no-dev --prefer-dist firefly-iii 5.6.14  

During the installation process, a number of questions may appear, we answer in the affirmative. After installation, you need to edit the Firefly III configuration file, specifying information about the database created earlier:

sudo nano /var/www/html/firefly-iii/.env

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=firefly_database
DB_USERNAME=fireflyuser
DB_PASSWORD=StrongPassword

After editing, save and close the file ctrl + o, ctrl + x:

Restart webserver and php:

sudo systemctl restart nginx php8.0-fpm

We initialize the Firefly III database, on a weak server configuration this may take some time:

cd /var/www/html/firefly-iii

sudo php artisan migrate:refresh --seed
sudo php artisan firefly-iii:upgrade-database
sudo php artisan passport:install

In conclusion, we grant rights to the Firefly III folder to the web server

sudo chown -R www-data:www-data firefly-iii
sudo chmod -R 775 firefly-iii/storage

To access Firefly III in the address bar of the browser, type the IP address of the server with the port specified during the nginx configuration (taking into account the instructions above, it will look something like this: 192.168.0.22:8080). The new user registration page will open, after registration it will be automatically disabled. Specify email and password.

During the initial setup, the interface language and the base currency are selected. It can be changed later. If the Russian language was not selected when installing Ububntu, then different locales may not be correctly displayed, which Firefly III will warn about. To fix the error, you need to install Russian localization and select it by default:

sudo dpkg-reconfigure locales

In the list that appears, select ru_RU.UTF-8, and in the next step set it by default. To apply the changes, restart ngnix and php.

If desired, for access not only from the local network, you can later configure https and get a certificate and hide the server behind reverse-proxy (in the latter case, the trusted proxy will need to be specified in the Firefly III settings file).

In addition to direct installation on the server, you can use the Docker image, but only Firefly III is present in the official image, you will have to separately configure the image of the web server and the database server and the connection between them. There is also an automatic installation script, but it has not been updated for a long time, in my case it did not work correctly. Information about the project and the possibilities of the service can be found on the project website https://docs.firefly-iii.org/.

A little about Firefly III. The structure of working with the finance manager may not be quite familiar to those who have used other accounting applications. For example, you need to create income and expense accounts. Let’s create an income account “Employer” and a main account. When creating an income transaction (for example, receiving a salary), specifies the required accounts and amount. As a result, we see that the specified amount has increased on the main account, and the same amount with a negative sign on the Employer account. When creating a transaction, you can add various information – cost category, tags, add a note, attach a file or convert to another currency, as well as divide the transaction into its component parts. Firefly III can build charts and draw up various reports on the entered expenses.

Firefly III Main Window
Firefly III Main Window

That’s all. I hope the setup instructions will be useful to someone.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *