Firefly LXC/KVM/Baremetal Install

Self-hosted financial manager.

Requirement

Recommended

Memory

512MB

Ports

Files

Install

Assumes Ubuntu installed with a local user account, with backup data mounted on /data/storage.

Dependencies

Install firefly denpendencies
apt install nginx curl php7.4 php7.4-cli php7.4-zip php7.4-gd php7.4-fpm php7.4-json php7.4-common php7.4-pgsql php7.4-zip php7.4-mbstring php7.4-curl php7.4-xml php7.4-bcmath php7.4-imap php7.4-ldap php7.4-intl

Set 512MB php limit.

0644 root root /etc/php/7.4/fpm/php.ini
memory_limit = 512MB
Install php composer for php dependency management.
wget https://getcomposer.org/installer
chmod +x installer
./installer -- --install-dir=/usr/local/bin --filename=composer
Remove default NGINX files.
rm /var/www/html/index.nginx-debian.html
rm /etc/nginx/sites-enabled/default

Install Versioned

Installing to a versioned directory enables easy migration to new versions.

https://api.github.com/repos/firefly-iii/firefly-iii/releases/latest

Install latest version.
cd /var/www/html/
tar xvf firefly-iii.tar.gz

Note

Latest version: https://api.github.com/repos/firefly-iii/firefly-iii/releases/latest

This should extract to firefly-iii-{VERSION}

Install php dependencies, set ownership, and link to latest version.
composer create-project grumpydictator/firefly-iii --no-dev --prefer-dist firefly-iii --no-interaction {VERSION}
sudo chown -R www-data:www-data firefly-iii
sudo chmod -R 775 firefly-iii/storage
ln -sf /var/www/html/firefly-iii-{VERSION} /var/www/html/firefly-iii
Link to storage.
rm /var/www/html/firefly-iii-{VERSION}/storage/{export,upload}
ln -sf /var/www/html/firefly-iii-{VERSION}/storage/export /var/www/html/firefly-iii/storage/export
ln -sf /var/www/html/firefly-iii-{VERSION}/storage/upload /var/www/html/firefly-iii/storage/upload
chown -R www-data:www-data /var/www/html/firefly-iii-{VERSION}/storage/{export,upload}
chmod -R 0775 /var/www/html/firefly-iii-{VERSION}/storage

Set logrotation.

0644 root root /etc/logrotate.d/firefly-iii
/opt/firefly-iii/storage/logs/*.log
{
  weekly
  missingok
  rotate 2
  compress
  notifempty
  sharedscripts
  maxage 60
}

Set the NGINX configuration to server firefly.

0640 root root /etc/nginx/sites-enabled/firefly.conf
server {
  listen       80 default_server;
  server_name  firefly.example.com firefly;
  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/php7.4-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)(/.+)$;
  }
}
0640 www-data www-data /var/www/html/firefly-iii/.env
APP_KEY={KEY}

TRUSTED_PROXIES=**

DB_CONNECTION=pgsql
DB_HOST=192.168.1.10
DB_PORT=5432
DB_DATABASE=firefly
DB_USERNAME=firefly
DB_PASSWORD={PASS}

APP_URL=http://localhost

Note

APP_KEY is alphanumeric string of 32 characters. Use php artisan key:generate to create it.

Set TRUSTED_PROXIES=** to enable proxy usage.

APP_URL this should remain localhost it does not effect proxied or non-proxied connections. Existing documentation on the web is wrong.

Proceed to Database Config.

Database Config

Majority of cases should use the DB migration instead of initalization; only use initalization if new DB or wiping existing DB contents are ok.

Migrate the database.
rm -rf /var/www/html/firefly-iii-{VERSION}/bootstrap/cache/*
php artisan cache:clear
php artisan migrate --seed
php artisan firefly-iii:upgrade-database
php artisan passport:install
php artisan cache:clear
Initialize the database.
php artisan migrate:refresh --seed
php artisan firefly-iii:upgrade-database
php artisan passport:install
Restart NGINX/php.
systemctl restart nginx php7.4-fpm

Updating Firefly

Install new version using the Install Versioned steps and Migrate the database.. Previous versions can be deleted.

Reference

Reference

Reference