help installing fava on vps

140 views
Skip to first unread message

Ali Kakakhel

unread,
Aug 28, 2018, 8:30:01 AM8/28/18
to Beancount
Hi all,

I am trying to get fava installed on my vps mainly as a teaching tool, but I need some help. I am able to reach https://fava.example.io/fava/huge-example-file/income-statement/ with my local machine's browser. This result suggests to me that fava is using a built in example file instead of my own main.beancount file. What I would like to be able to do is three-fold:
  • Use my own main.beancount file.
  • Access from https://fava.example.io/
  • The demo has a dropdown menu to switch between various files. How can I have the same feature?
I tried to change --prefix /fava to --prefix /, but nothing changed. I used the following pseudo-script on my vps for my setup.

alice@vps ~$ sudo apt-get install python3-pip3
alice@vps ~$ sudo pip3 install beancount
alice@vps ~$ sudo pip3 install fava
alice@vps ~$ sudo nano /etc/systemd/system/fava.service
"""
[Unit]
Description=Fava Web UI for Beancount

[Service]
Type=simple
ExecStart=/usr/local/bin/fava --host localhost --port 5000 --prefix /fava /home/alice/beancount/main.beancount
User=alice
"""

alice@vps ~$ sudo nano /etc/apache2/sites-available/fava.example.io.conf
"""
<VirtualHost *:80>
ServerAdmin ad...@example.io
ServerName fava.example.io
ServerAlias www.fava.example.io
#DocumentRoot /var/www/fava.example.io/html
Redirect / https://fava.example.io
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
"""

alice@vps ~$ sudo mkdir -p /var/www/fava.example.io/html
alice@vps ~$ sudo nano /etc/apache2/sites-available/fava.example.io-le-ssl.conf
"""
<VirtualHost *:443>
ServerAdmin ad...@example.io
ServerName fava.example.io
ServerAlias www.fava.example.io
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

ProxyPreserveHost On
ProxyRequests off
ProxyPass / http://localhost:5000/
ProxyPassReverse / http://localhost:5000/

# Example SSL configuration
SSLEngine on
SSLProtocol -ALL -SSLv2 -SSLv3 +TLSv1 +TLSv1.1 +TLSv1.2
SSLHonorCipherOrder on
SSLCipherSuite TLSv1.2:RC4:HIGH:!aNULL:!eNULL:!MD5
SSLCompression off
TraceEnable Off
#SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
SSLCertificateFile "/etc/letsencrypt/live/example.io/fullchain.pem"
SSLCertificateKeyFile "/etc/letsencrypt/live/example.io/privkey.pem"
</VirtualHost>
"""

alice@vps ~$ sudo a2enmod proxy proxy_http
alice@vps ~$ sudo a2ensite fava.example.io.conf
alice@vps ~$ sudo a2ensite fava.example.io-le-ssl.conf
alice@vps ~$ sudo systemctl restart apache2
alice@vps ~$ mkdir beancount
alice@vps ~$ cd beancount
alice@vps ~$ wget https://raw.githubusercontent.com/beancount/fava/master/contrib/examples/huge-example.beancount
alice@vps ~$ mv huge-example.beancount main.beancount
alice@vps ~$ sudo systemctl start fava


Vivek Gani

unread,
Aug 30, 2018, 6:43:41 PM8/30/18
to Beancount
  • Use my own main.beancount file.
  • The demo has a dropdown menu to switch between various files. How can I have the same feature?
    From my understanding fava doesn't look at things in your current directory. It either:
      Requires your beancount file to be being passed in the filepath as an argument e.g. `$fava main.beancount` or
      you have the file path set via the BEANCOUNT_FILE environment variable.

    In both cases, you can have multiple (space delimited) file paths. see https://github.com/beancount/fava/blob/master/fava/cli.py#L36

    Ali Kakakhel

    unread,
    Sep 3, 2018, 9:44:32 AM9/3/18
    to Beancount
    Thanks for the reply.

    I will try to use the environment variable method and report back.

    In the service file, I set the ExecStart value as follows.

    ExecStart=/usr/local/bin/fava --host localhost --port 5000 --prefix /fava /home/alice/beancount/main.beancount

    That last item is the path to the main.beancount file. Does fava act as a user that does not have permission to read the file in that location?

    Stefano Zacchiroli

    unread,
    Sep 3, 2018, 9:58:25 AM9/3/18
    to bean...@googlegroups.com
    On Mon, Sep 03, 2018 at 06:44:32AM -0700, Ali Kakakhel wrote:
    > In the service file, I set the ExecStart value as follows.
    >
    > ExecStart=/usr/local/bin/fava --host localhost --port 5000 --prefix /fava /
    > home/alice/beancount/main.beancount
    >
    > That last item is the path to the main.beancount file. Does fava act as a
    > user that does not have permission to read the file in that location?

    By default systemd services are run as root (see systemd.exec(5)). So it
    should work, but it is probably not a great idea for running Fava. What
    I personally do is tell systemd to run fava as my own user. My main
    Beancount file is readable/writable by that user. FWIW, here's my
    service file:

    ------------------
    $ cat /etc/systemd/system/fava.service
    [Unit]
    Description=Fava Web UI for Beancount, running on Zack's ledger

    [Service]
    Type=simple
    ExecStart=/usr/local/bin/fava --prefix /beancount /path/to/main.beancount
    User=zack
    ------------------

    Hope this helps,
    Cheers
    --
    Stefano Zacchiroli . za...@upsilon.cc . upsilon.cc/zack . . o . . . o . o
    Computer Science Professor . CTO Software Heritage . . . . . o . . . o o
    Former Debian Project Leader & OSI Board Director . . . o o o . . . o .
    « the first rule of tautology club is the first rule of tautology club »

    Jakob Schnitzer

    unread,
    Sep 3, 2018, 12:17:27 PM9/3/18
    to bean...@googlegroups.com
    On Tue, Aug 28, 2018 at 05:30:01AM -0700, Ali Kakakhel wrote:
    >Hi all,
    >
    >I am trying to get fava installed on my vps mainly as a teaching tool, but
    >I need some help. I am able to reach
    >https://fava.example.io/fava/huge-example-file/income-statement/ with my
    >local machine's browser. This result suggests to me that fava is using a
    >built in example file instead of my own main.beancount file. What I would
    >like to be able to do is three-fold:
    >
    >[...]
    >
    >alice@vps ~$ wget
    >https://raw.githubusercontent.com/beancount/fava/master/contrib/examples/huge-example.beancount
    >alice@vps ~$ mv huge-example.beancount main.beancount

    Here you move Fava's file example to `main.beancount`, so it's not very
    surprising that the example file is used.

    Best,
    Jakob

    Ali Kakakhel

    unread,
    Sep 4, 2018, 10:50:54 PM9/4/18
    to Beancount
    I now have Fava running with multiple example files for different entity types (barebones as they are) by placing the files in a [space] separated list in the service file.

    Removing the --prefix /fava from the service file also removed the (undesired, in my case) /fava in the url.

    Jakob's answer made me think that maybe Fava uses the beancount file's title option in the path. If I change the title, I have to correspondingly change the name in the url. I had assumed that Fava was somehow unable to access the file I provided so it defaulted to the example provided.



    The only issue now is that Fava will mistakenly default to https://fava.example.iohuge-example-file/income_statement/ rather than the correct https://fava.example.io/huge-example-file/income_statement/

    Note the missing / after the .io tld.
    Reply all
    Reply to author
    Forward
    0 new messages