---
# System prepended metadata

title: HAPI FHIR installation
tags: [CyLab]

---

###### tags: `CyLab`
# HAPI FHIR installation
os : ubuntu server 20 LTS
## PostgreSQL 14
### install PostgreSQL 14
```
user@fhir:~$ sudo apt -y install postgresql-14
```
### set up PostgreSQL 14
check PostgreSQL
```
user@fhir:~$ sudo systemctl status postgresql
● postgresql.service - PostgreSQL RDBMS
     Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
     Active: active (exited) since Fri 2022-08-26 04:59:08 UTC; 1min 36s ago
   Main PID: 4284 (code=exited, status=0/SUCCESS)
      Tasks: 0 (limit: 1065)
     Memory: 0B
     CGroup: /system.slice/postgresql.service

Aug 26 04:59:08 fhir systemd[1]: Starting PostgreSQL RDBMS...
Aug 26 04:59:08 fhir systemd[1]: Finished PostgreSQL RDBMS.
```
enable PostgreSQL at startup
```
user@fhir:~$ sudo systemctl enable postgresql@
```

PostgreSQL create user and database
```
user@fhir:~$ sudo passwd postgres
New password: 
Retype new password: 
passwd: password updated successfully
user@fhir:~$ su postgres
Password: 
postgres@fhir:/home/user$ psql -c "ALTER USER postgres WITH PASSWORD 'password';"
ALTER ROLE
postgres@fhir:/home/user$ psql
psql (14.5 (Ubuntu 14.5-1.pgdg20.04+1))
Type "help" for help.

postgres=# create user fhir with encrypted password 'hapifhir';
CREATE ROLE
postgres=# create database hapifhir with owner fhir template template0;
\CREATE DATABASE
postgres=# create database hapifhir with owner fhir template template0;
ERROR:  database "hapifhir" already exists
postgres=# grant ALL privileges on database hapifhir to fhir;
GRANT
postgres=# alter database hapifhir set timezone to 'ROC';
ALTER DATABASE
postgres=# \q
```

## HAPI FHIR
clone repo
```
user@fhir:~$ git clone https://github.com/hapifhir/hapi-fhir-jpaserver-starter
Cloning into 'hapi-fhir-jpaserver-starter'...
remote: Enumerating objects: 5366, done.
remote: Counting objects: 100% (79/79), done.
remote: Compressing objects: 100% (61/61), done.
remote: Total 5366 (delta 20), reused 40 (delta 6), pack-reused 5287
Receiving objects: 100% (5366/5366), 1.85 MiB | 5.33 MiB/s, done.
Resolving deltas: 100% (1931/1931), done.
```
