Skip to content

Instantly share code, notes, and snippets.

@aadhilpm
Last active November 7, 2023 16:30
Show Gist options
  • Save aadhilpm/132b272fcdd4a57b375d80178cce9a98 to your computer and use it in GitHub Desktop.
Save aadhilpm/132b272fcdd4a57b375d80178cce9a98 to your computer and use it in GitHub Desktop.
Alf.io Manual Installation.md
gists
id url createdAt updatedAt filename isPublic
132b272fcdd4a57b375d80178cce9a98
2023-01-25T10:15:40Z
2023-01-25T10:15:41Z
Alf.io Setup & Manual Installation.md
true

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

  • Ubuntu 22.04.1 LTS
  • Point your Domain to the Server

Create a New User

sudo adduser alfio

Add sudo permissions to the user we created alfio

sudo usermod -aG sudo alfio
su alfio

Java Developement Kit

To run Alf.io we need to install the Java Developement Kit

sudo apt update
sudo apt install openjdk-17-jdk
sudo apt install openjdk-17-jre
java --version

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 alfiodb databse.


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

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
  • Point your domian to IP address
sudo vi /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;
	proxy_set_header  X-Real-IP $remote_addr;
	proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
	proxy_set_header  Host $http_host;
	proxy_set_header  X-Forwarded-Proto $scheme;
	}
} 

SSL certificates

Install snapd and update

sudo apt install snapd
sudo snap install core; sudo snap refresh core

Remove existing installations of certbot & Install certbot

sudo apt-get remove certbot
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot

For one step automatic ssl installation & fill the details based command displayed on the screen

sudo certbot --nginx

Lets restart nginx

sudo systemctl restart nginx

Alf configuration

cd /home/alfio/

To get the link to the latest version of Alf.io on the release page, go to https://github.com/exteso/alf.io/releases. From there, you can download the .war file by clicking on the "Assets" button next to the latest release.

wget https://github.com/alfio-event/alf.io/releases/download/2.0-M4-2301/alfio-2.0-M4-2301-boot.war

To create a config file named "application.properties" with specific content, you can use the following command in a terminal:

vi application.properties

And add following code and use same database name and password which you added on PostgreSQL

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

To save vim file Press the Esc key to exit insert mode, if you are in it. You can save and exit the editor in one command by typing :wq and then pressing Enter.

systemd script

We can create systemd script for starting at boot and running in background. A systemd script is a script or configuration file that is used to control the behavior of a service managed by the systemd init system. These scripts, also known as unit files, specify how the service should be started, stopped, and restarted, as well as other options such as dependencies and resource limits. They are typically stored in the /etc/systemd/system directory, and can be controlled using the systemctl command.

cd /home/alfio
ls

copy the .war file name and create start.sh

sudo vi start.sh

add following code and replace the .war file name and path of java if it if required

#!/bin/sh
/usr/bin/java -jar /home/alfio/alfio-2.0-M4-2301-boot.war -Xms100M -Xmx256M > startup.log 2>&1

sudo chmod 744 start.sh

cd /etc/systemd/system/
sudo vi alfio.service
  • add following code in this perticular file

[Unit]
Description=alfio
After=postgresql.service
Requires=postgresql.service

[Service]
User=alfio
WorkingDirectory=/home/alfio
ExecStart=/home/alfio/start.sh
ExecStop=/bin/kill -TERM $MAINPID
Restart=always

[Install]
WantedBy=multi-user.target

sudo chmod 644 alfio.service

cd /home/alfio

sudo systemctl enable alfio.service
sudo systemctl start alfio.service

cd logs/
vi alfio.log

Copy the administrator password from alfio.log file Note: admin password cannot be reset without accessing the application.

If in case you can't find log details on startup.log and alfio.log and restart the mechine and see

You can access your admin panel @ yourdomain.com/admin username is admin and password is the one copied from alfio.log file

References:

A special thank you to the Alf.io team for making this amazing ticket reservation system for conferences, trade shows, workshops, and meetups open source. We appreciate all the hard work and dedication that went into creating this project.

Hope this tutorial is helpful and let me know you feedback

@emoshofc
Copy link

emoshofc commented Jan 25, 2023

Hey,

first of all many many thanks for this detailed tutorial!

Nevertheless, I can't get alf.io to work. I wish I knew what I'm doing wrong.

Do you think you can help me? I would be very grateful.

Your tutorial is already very detailed, but probably missing something somewhere that I do not understand as a beginner.
A video would not be feasible for you, right?

Many thanks
Emircan

@tobsowo
Copy link

tobsowo commented Apr 11, 2023

Thank you for this guide.
I ran into some errors.

I could not install snap
alfio@alfio:~$ sudo snap install core
error: system does not fully support snapd: cannot mount squashfs image using "squashfs": mount:
/tmp/syscheck-mountpoint-1210983158: mount failed: Operation not permitted.

So, I skipped the SSL part but after following all the process, I am unable to access the web and this is what I have in log

[INFO ] 2023-04-11 20:59:08.844 [main] SpringBootLauncher - Starting SpringBootLauncher using Java 17.0.6 on alfio with PID 7105 > [INFO ] 2023-04-11 20:59:08.857 [main] SpringBootLauncher - The following 2 profiles are active: "spring-boot", "jdbc-session" [ERROR] 2023-04-11 20:59:12.290 [main] HikariPool - HikariPool-1 - Exception during pool initialization. org.postgresql.util.PSQLException: FATAL: password authentication failed for user "alfio" at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:613) ~[postgresql-42.2.25.jar> at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:161) ~[postgresql-42.2.25.jar!/:42.> at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:213) ~[postgresql-42.2.25.j> at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:51) ~[postgresql-42.2.25.jar!/:42.2.25] at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:225) ~[postgresql-42.2.25.jar!/:42.2.25] at org.postgresql.Driver.makeConnection(Driver.java:465) ~[postgresql-42.2.25.jar!/:42.2.25] at org.postgresql.Driver.connect(Driver.java:264) ~[postgresql-42.2.25.jar!/:42.2.25] at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) ~[HikariCP-4.0.3.jar!/:?] at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:364) ~[HikariCP-4.0.3.jar!/:?] at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206) ~[HikariCP-4.0.3.jar!/:?] at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:476) ~[HikariCP-4.0.3.jar!/:?] at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561) ~[HikariCP-4.0.3.jar!/:?] at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115) ~[HikariCP-4.0.3.jar!/:?] at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) ~[HikariCP-4.0.3.jar!/:?] at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:159) ~[spring-jdbc-5.3.18.jar> at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:117) ~[spring-jdbc-5.3.18.jar> at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80) ~[spring-jdbc-5.3.18.jar!/:> at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:646) ~[spring-jdbc-5.3.18.jar!/:5.3.18] at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:713) ~[spring-jdbc-5.3.18.jar!/:5.3.18] at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:738) ~[spring-jdbc-5.3.18.jar!/:5.3.18] at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:794) ~[spring-jdbc-5.3.18.jar!/:5.3.18] at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.queryForObject(NamedParameterJdbcTemplate.java:243> at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.queryForObject(NamedParameterJdbcTemplate.java:260> at alfio.config.DataSourceConfiguration.getDataSource(DataSourceConfiguration.java:118) ~[classes!/:?]

@tobsowo
Copy link

tobsowo commented Jul 25, 2023

Please can you help with how to update.

Thank you.

@charlotteea7
Copy link

thanks for update

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