Skip to content

Instantly share code, notes, and snippets.

@flexwie
Last active August 23, 2023 12:22
Show Gist options
  • Save flexwie/a8572e8e7ef06ae844925ec857fa3b5b to your computer and use it in GitHub Desktop.
Save flexwie/a8572e8e7ef06ae844925ec857fa3b5b to your computer and use it in GitHub Desktop.
How to install Alf.io manually

Alf.io Manual Installation

This is a quick guide on how to install Alf.io manually on a fresh machine.

Prerequisites

The following are neccessay to follow this quick start guide:

  • Server running Ubuntu 16.04
  • Domain pointed to the Server

JDK8

To run Alf.io we need to install the Java Developement Kit 8 (jdk8). First, add Oracles PPA and update the package repository.

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update

Then install jdk8 and confirm the TOS.

sudo apt-get install openjdk-8-jre -y

PostgreSQL

Next we are going to set the database for Alf.io up. Enter this to install PostgreSQL.

sudo apt-get install postgresql postgresql-contrib -y

When finished, we will access the CLI.

sudo -u postgres psql

Once accessed, we will create a new user, and grant him all privileges on the alfio databse.

CREATE USER alfio WITH ENCRYPTED PASSWORD '<YOUR_POSTGRESQL_PASSWORD_HERE>';
CREATE DATABASE alfio;
GRANT ALL PRIVILEGES ON DATABASE "alfio" to alfio;

Mailserver

To have Alf.io send mail you need to eather install a SMTP server like Postfix or use an existing provider like Mailjet.

nginx

To make the application accessible from the internet, we will need to reverse proxy it with nginx. Install nginx with this command and edit the configuration.

sudo apt-get install nginx -y
sudo nano /etc/nginx/sites-available/default

Remove the default settings and replace them with the following.

server {
  listen 80;
  server_name <YOUR_DOMAIN_NAME>;
  
  location / {
    proxy_pass http://localhost:8080;
  }
}

Now we add SSL certificates provided by LetsEncrypt. Add the repository and install their certbot.

sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install python-certbot-nginx

To accquire the certificates run sudo certbot --nginx -d <YOUR_DOMAIN_NAME>. If you manage multiple domains just add a -d <YOUR_DOMAIN_NAME> for each. If this was successful the bot will ask you to accept the TOS and for your mailaddress. Afterwards it will ask you if it should redirect all traffic to SSL, just confirm by choosing the second option. Restart nginx with service nginx restart.

Security

TO secure the server we will add a very basic firewall with ufw.

sudo apt-get install ufw

Optional: If your server is using IPv6, make sure to edit /etc/default/ufw and set IPV6=yes.

Add default policies to deny any incoming requests and allow all outgoing.

sudo ufw default deny incoming
sudo ufw default allow outgoing

Then add a rule for all ports we are using.

sudo ufw allow ssh
sudo ufw allow 80
sudo ufw allow 443

Remember that you will need to enable every other port you want to use in the future, like FTP (Port 21) for example. You can run sudo ufw status verbose to see your configuration. If everything is to your liking, enable ufw with sudo ufw enable

Alf.io jar and configuration

Get the link to the latest version of Alf.io on the release page. Create a directory and download the .war-file inside.

sudo mkdir /var/alfio
cd /var/alfio
wget <ALFIO_LINK>

Create a config file named application.properties with this content.

datasource.dialect=PGSQL
datasource.driver=org.postgresql.Driver
datasource.url=jdbc:postgresql://localhost:5432/alfio
datasource.username=alfio
datasource.password=<YOUR_POSTGRESQL_PASSWORD_HERE>
datasource.validationQuery=SELECT 1
spring.profiles.active=dev

Run and autostart

Now you can run java -jar <FILE_NAME> > alfio.log 2>&1 & and should have a running Alf.io instance! You can see the admin password in the log.

@cbellone
Copy link

cbellone commented Dec 18, 2017

  1. Do I need to create the user myself?

yes, you need to create the user "alfio". Please make sure that the home directory is "/home/alfio/"

Thank you!

@headarrow
Copy link

spring.profiles.active=dev its says development mode but if i remove this from application.properties it ERR_TOO_MANY_REDIRECTS
how i can fix that? i dont want development mode

@jfbethlehem
Copy link

jfbethlehem commented Jan 7, 2023

This is my working apache sites-file for my site:

<IfModule mod_ssl.c>
<VirtualHost *:443>
    DocumentRoot "/var/www/myhost.com/"
    ServerName myhost.com
    <Directory "/var/www/myhost.com">
        Options SymLinksIfOwnerMatch
        Require all granted
        Allowoverride all
    </Directory>
    RewriteEngine on

    ProxyPreserveHost On
    ProxyPass / http://127.0.0.1:8081/
    ProxyPassReverse / http://127.0.0.1:8081/
    RemoteIPHeader X-Forwarded-For
    RemoteIPHeader X-Real-IP
    RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
    RequestHeader set "X-Forwarded-SSL" expr=%{HTTPS}

    Include /etc/letsencrypt/options-ssl-apache.conf
    SSLCertificateFile /etc/letsencrypt/live/myhost.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/myhost.com/privkey.pem
</VirtualHost>
</IfModule>

@tobsowo
Copy link

tobsowo commented Aug 2, 2023

Please how do I update Alfio

@jfbethlehem
Copy link

Please how do I update Alfio

download the latest .jar file from alfio, replace the existing .jar with the new .jar, run the new .jar. done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment