How to install Gotify on Ubuntu Server
Gotify is a self-hosted server for pushing notifications. In this tutorial, we will guide you on how to install Gotify on Ubuntu Server.
Prerequisites
Before starting, ensure you have the following:
- A Linux Ubuntu Server Latest instance with root access or sudo privileges.
- A non-root user with sudo privileges.
Step 1: Update Ubuntu Server
Firstly, you need to update your Ubuntu Server’s packages to the latest version. To do so, follow the below commands:
sudo apt update
sudo apt upgrade
Step 2: Install the Required Dependencies
Gotify requires some dependencies to be installed on the system. Run the following command to install these dependencies:
sudo apt install curl git
Step 3: Install the Go Language
Gotify requires the Go language to run on the system. Follow the below steps to install Go:
Go to the official Go website (https://golang.org/dl/) and download the latest version of Go in tar.gz format.
Extract the downloaded file to the /usr/local directory using the following command:
sudo tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gzWe need to set the PATH environment variable to the 'Go bin' path. To do so, add the following line in the '/etc/profile.d/go.sh' file using a text editor:
export PATH=$PATH:/usr/local/go/binLoad the changes to the system using the following command:
source /etc/profile.d/go.shVerify the Go installation by running the following command:
go version
Step 4: Install and Configure Gotify
Follow the below steps to install and configure the Gotify server:
Download the latest stable release of Gotify from the official website (https://github.com/gotify/server/releases/latest).
curl -LJO https://github.com/gotify/server/releases/latest/download/gotify-linux-amd64.zipExtract the downloaded file to the '/opt' directory using the following command:
sudo unzip -d /opt gotify-linux-amd64.zipCreate a new system user to run the Gotify server.
sudo useradd --home-dir /var/lib/gotify --shell /usr/sbin/nologin --system gotifyChange the ownership of the '/opt/gotify' directory to the newly created 'gotify' user.
sudo chown -R gotify:gotify /opt/gotifyCreate a new systemd service file to control the Gotify server using the following command:
sudo vi /etc/systemd/system/gotify.serviceCopy the following contents to the file:
[Unit] Description=Gotify Push Notification Server [Service] User=gotify Group=gotify WorkingDirectory=/opt/gotify ExecStart=/opt/gotify/gotify serve KillMode=process Restart=on-failure [Install] WantedBy=multi-user.targetReload the systemd system.
sudo systemctl daemon-reloadStart the Gotify service and enable it to start automatically at system boot.
sudo systemctl enable --now gotifyVerify the Gotify service's status.
sudo systemctl status gotify
Step 5: Configure the Firewall
By default, the firewall blocks the ports that the Gotify server uses. We need to allow ports 80, 443 and 6789 for HTTP, HTTPS, and Gotify respectively. Run the following commands:
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw allow 6789/tcp
sudo ufw enable
Conclusion
Congratulations! You have successfully installed and configured the Gotify server on your Ubuntu Server. You can now easily send push notifications from your application through the Gotify server.