In this guide I assume you want to use SQLite as storage mechanism. I used Ubuntu 18.04 but there should be no real differences between the different versions/distributions as long as it has systemd installed.
All commands are executed as root
. If you do not want to do this, prefix them with sudo [command]
.
You'll need the tool unzip
. If you didn't install it yet or don't know if it is installed just execute apt install -y unzip
.
Parts of this guide are taken from this guide and are modified for Gotify.
I used the following paths:
App: /opt/gotify/
Config: /opt/gotify/config.yml
Data: /opt/gotify/data/
You of course be more compliant with the linux directories and use this structure:
App: /usr/local/bin/gotify
Config: /etc/gotify/config.yml
Data: /var/lib/gotify/
Choose what you want and look for placeholders and replace the values appropiatly in the config files/commands we are using throughout this guide. Now for my approach we would create the directory like this, as I prefer to have all server applications in the /opt
directory:
mkdir -p /opt/gotify
cd /opt/gotify
First you have to get the download link to the binary of your architecture. Find the newest release here and replace <releaseurl>
.
Download the release package to gotify-download.zip and unzip it.
wget -O gotify-download.zip <releaseurl>
unzip gotify-download.zip
Rename the executable file to a more intuitive name and set permissions.
mv gotify-<os>-<arch> gotify
sudo chown root:root gotify
sudo chmod 755 gotify
Create a group and user for running the app.
groupadd -r gotify
useradd -M -d /opt/gotify -s /sbin/nologin -r -g gotify gotify
Put your configuration into the configuration file config.yml
. It does not exist yet so you need to create it. Here is the configuration I used. Remember to change the password! Also for Caddy the port needs to be somewhat other than 80 or 443. I chose 3000 as its free on my machine but you might change it if you want to or the port is already in use. You might also change the paths according to your desired directory structure.
server:
listenaddr: "127.0.0.1" # the address to bind on, leave empty to bind on all addresses
port: 3000 # the port for the http server
ssl:
enabled: false # if https should be enabledeave empty to bind on all addresses
letsencrypt:
enabled: false # if the certificate should be requested from letsencrypt
responseheaders: # response headers are added to every response (default: none)
Access-Control-Allow-Origin: "*"
Access-Control-Allow-Methods: "GET,POST"
database: # see below
dialect: sqlite3
connection: data/gotify.db
defaultuser: # on database creation, gotify creates an admin user (these values will only be used for the first start, if you want to edit the user after the first start use the WebUI)
name: admin # the username of the default user
pass: somesupersecurepassword123!!! # the password of the default user
passstrength: 10 # the bcrypt password strength (higher = better but also slower)
uploadedimagesdir: data/images # the directory for storing uploaded images
pluginsdir: data/plugins # the directory where plugin resides (leave empty to disable plugins)
Then assign the correct permissions to the configuration file.
chown root:root config.yml
chmod 644 config.yml
Create the data directory with correct permissions.
mkdir /opt/gotify/data
chown -R gotify:gotify /opt/gotify/data
chmod -R 755 /opt/gotify/data
You can test if you set it up correctly until now by executing this command:
sudo -u gotify ./gotify
If you see something like server started
and no errors everything is fine and you can exit again using Ctrl + C
.
Save this systemd service to /etc/systemd/system/gotify.service
. Remember to replace the paths according to your situation if you wanted to change them.
[Unit]
Description=Gotify Push Notification Server
Documentation=https://gotify.net/docs
After=network-online.target
Wants=network-online.target systemd-networkd-wait-online.service
StartLimitIntervalSec=14400
StartLimitBurst=10
[Service]
Restart=on-abnormal
User=gotify
Group=gotify
WorkingDirectory=/opt/gotify
ExecStart=/opt/gotify/gotify
PrivateTmp=true
ProtectSystem=full
ReadWritePaths=/opt/gotify/data
ReadWriteDirectories=/opt/gotify/data
TimeoutStopSec=5s
[Install]
WantedBy=multi-user.target
Set the appropiate permissions for the service file.
chown root:root /etc/systemd/system/gotify.service
chmod 644 /etc/systemd/system/gotify.service
Tell systemd to reload and run it.
systemctl daemon-reload
systemctl start gotify.service
You can verify if it worked by executing the following command and seeing the same output like in the previous test.
systemctl status gotify.service
If you want to enable the autostart after boot you can enable it like this:
systemctl enable gotify.service
Add the following to your Caddyfile
. If you set another port than 3000 remember to change it here too.
<domain> {
proxy / localhost:3000 {
transparent
websocket
}
}
Restart caddy and everything should be done.
systemctl restart caddy
Test by going to https://<domain>/
.
- Consider removing the admin password from the
config.yml
or change to another to prevent forgetting to change and other people getting access to the admin panel.
systemclt enable gotify.service
should be
systemctl enable gotify.service