This guide provides a full Ansible playbook to deploy Firefly III natively on Debian 10+, Ubuntu LTS, and RHEL 9+ compatible hosts without Docker.
- name: Deploy Firefly III (Native)
hosts: firefly-iii
become: true
vars:
app_root: /var/www/firefly-iii
app_user: www-data
app_group: www-data
app_port: 8082
db_name: firefly
db_user: firefly
db_password: "{{ vault_firefly_db_password | default('change-me') }}"
tasks:
- name: Install dependencies on Debian/Ubuntu
apt:
name:
- apache2
- mariadb-server
- mariadb-client
- php
- php-mysql
- php-curl
- php-zip
- php-gd
- php-mbstring
- php-xml
- php-bcmath
- php-intl
- libapache2-mod-php
- git
- unzip
state: present
update_cache: true
when: ansible_os_family == "Debian"
- name: Enable and start services
service:
name: "{{ item }}"
state: started
enabled: true
loop:
- mariadb
- apache2
when: ansible_os_family == "Debian"
- name: Create application directory
file:
path: "{{ app_root }}"
state: directory
owner: "{{ app_user }}"
group: "{{ app_group }}"
mode: "0755"
- name: Clone Firefly III repository
git:
repo: https://github.com/firefly-iii/firefly-iii.git
dest: "{{ app_root }}"
version: main
become_user: "{{ app_user }}"
- name: Copy environment file
copy:
src: "{{ app_root }}/.env.example"
dest: "{{ app_root }}/.env"
owner: "{{ app_user }}"
group: "{{ app_group }}"
mode: "0644"
remote_src: true
- name: Configure database connection
lineinfile:
path: "{{ app_root }}/.env"
regexp: "^{{ item.key }}="
line: "{{ item.key }}={{ item.value }}"
loop:
- { key: 'DB_HOST', value: 'localhost' }
- { key: 'DB_DATABASE', value: "{{ db_name }}" }
- { key: 'DB_USERNAME', value: "{{ db_user }}" }
- { key: 'DB_PASSWORD', value: "{{ db_password }}" }
- name: Create database
mysql_db:
name: "{{ db_name }}"
state: present
login_unix_socket: /var/run/mysqld/mysqld.sock
login_user: root
- name: Create database user
mysql_user:
name: "{{ db_user }}"
password: "{{ db_password }}"
priv: "{{ db_name }}.*:ALL"
state: present
login_unix_socket: /var/run/mysqld/mysqld.sock
login_user: root
- name: Install Composer
shell: |
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
args:
creates: /usr/local/bin/composer
- name: Install PHP dependencies
composer:
command: install
working_dir: "{{ app_root }}"
become_user: "{{ app_user }}"
- name: Generate application key
command: php artisan key:generate
args:
chdir: "{{ app_root }}"
become_user: "{{ app_user }}"
- name: Run database migrations
command: php artisan migrate --seed
args:
chdir: "{{ app_root }}"
become_user: "{{ app_user }}"
- name: Set directory permissions
file:
path: "{{ item }}"
owner: "{{ app_user }}"
group: "{{ app_group }}"
recurse: true
loop:
- "{{ app_root }}/storage"
- "{{ app_root }}/bootstrap/cache"
- name: Create Apache virtual host
copy:
dest: /etc/apache2/sites-available/firefly-iii.conf
mode: "0644"
content: |
<VirtualHost *:{{ app_port }}>
ServerAdmin webmaster@localhost
DocumentRoot {{ app_root }}/public
<Directory {{ app_root }}>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/firefly-iii_error.log
CustomLog ${APACHE_LOG_DIR}/firefly-iii_access.log combined
</VirtualHost>
when: ansible_os_family == "Debian"
- name: Enable Apache site
command: a2ensite firefly-iii
args:
creates: /etc/apache2/sites-enabled/firefly-iii.conf
when: ansible_os_family == "Debian"
- name: Restart Apache
service:
name: apache2
state: restarted
when: ansible_os_family == "Debian"
http://SERVER-IP:8082.Beyond this playbook, we offer:
Contact our automation team: office@linux-server-admin.com