Install and Configure YAFFA on Raspberry Pi
This guide will help you install a basic working instance of YAFFA on your Raspberry Pi. It will guide you through the installation of YAFFA web application itself. This guide assumes that you have already set up your Raspberry Pi with a LEMP stack.
For a brief guide on how to set up a LEMP stack on a Raspberry Pi, see this guide. For more detailed instructions or help with troubleshooting, you can refer to the official documentation of the software components or search the internet for more detailed guides.
1. Download YAFFA
As a first step, you need to download the files of YAFFA. For this, we will use Composer, a dependency manager for PHP.
First, navigate to the directory where you want to install YAFFA. If you followed our guide, then you can head to the folder we created at /var/www/yaffa
:
cd /var/www/yaffa
Make sure that the folder is empty, and then download YAFFA using Composer:
git clone https://github.com/kantorge/yaffa.git . --branch main
2. Prepare your database
YAFFA stores its data in a MySQL database. This includes various assets like accounts, payees, categories, and also the transactions you record. You need to create a new database and a user with the necessary permissions to access it.
- Open your MySQL client, and log in as the root user. You can use the following command:
sudo mysql -u root -p
Let's create a user and a database for YAFFA. You can replace yaffa
with your desired username, password
with your desired password, and yaffa
with your desired database name. In this case, make the necessary changes in the code snippets below:
CREATE DATABASE yaffa;
CREATE USER 'yaffa'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON yaffa.* TO 'yaffa'@'localhost';
FLUSH PRIVILEGES;
You can now exit the MySQL client:
exit
3. Install packages
Before you can start using YAFFA, you need to install the necessary packages. This includes Composer, which is a dependency manager for PHP, and NPM, which is a package manager for JavaScript. At this point we assume that you have Composer installed.
- Install the necessary PHP packages:
composer install --no-dev --no-scripts
The end result should look like this:
4. Configure YAFFA
As any Laravel application, YAFFA needs to be configured to work with your environment. This includes setting up the database connection, application key, and other settings. This guide covers the base configuration, but you can find more advanced settings in the .env
file. Some of these are also covered in the Advanced settings guide.
- The settings of YAFFA will be stored in a
.env
file. While still in your YAFFA folder and your terminal, make a copy of the sample.env
file:
cp .env.example .env
- One important setting is the application key. It can be edited in the newly created
.env
file directly, or it can be created by running the following command:
php artisan key:generate
At this point, you can open the .env
file in your favorite text editor and adjust the settings to match your environment.
nano .env
- Set the database connection parameters according to the values you have used to create the MySQL user and database. Use the
DB_DATABASE
,DB_USERNAME
andDB_PASSWORD
settings accordingly. - Review the APP_URL, if you would like to use something else than the IP address of the Raspberry Pi to access YAFFA from your browser.
5. Build the database
In an earlier step you created a database and a user for YAFFA. Now it's time to create the tables and relationships that YAFFA needs to function. Fortunately, Laravel provides a convenient way to do this. In the command prompt, from the directory where YAFFA is installed, run the following command to create all the database tables, that are used by YAFFA.
php artisan migrate
Your output should look similar to this:
6. Set up the storage
YAFFA uses the storage
directory to store various files, like logs, cache, and uploaded files. You need to set the correct permissions for this directory.
sudo chown -R www-data:www-data storage bootstrap/cache
sudo chmod -R 775 storage bootstrap/cache
7. Set up the web server
YAFFA is a web application, so you need to configure your web server to serve the application. In this guide, we will use Nginx as the web server. You might have this configuration in place if you followed our guide on how to set up a LEMP stack on a Raspberry Pi. You still need to make some adjustments to the configuration to serve YAFFA.
- Create a new server block for YAFFA:
sudo nano /etc/nginx/sites-available/yaffa
Paste the following configuration into the file. Make sure to adjust the server_name
and root
directives to match your environment.
server {
listen 80;
server_name yaffa.local;
root /var/www/yaffa/public;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Enable the configuration if you haven't done so already, and reload Nginx:
sudo ln -s /etc/nginx/sites-available/yaffa /etc/nginx/sites-enabled/
sudo systemctl reload nginx
8. Test your YAFFA installation
You can now open your browser and navigate to the IP address of your Raspberry Pi, or the domain you have set up in the Nginx configuration. You should see the YAFFA login screen.
Congratulations! You have successfully installed YAFFA on your Raspberry Pi. You can now log in and start using the application. Enjoy managing your finances with ease! If you encounter any issues, refer to our documentation or reach out to us for assistance.
For instructions on the first steps to start using YAFFA, please visit the guide on the registration.