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:

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:

  1. Go to the official Go website (https://golang.org/dl/) and download the latest version of Go in tar.gz format.

  2. Extract the downloaded file to the /usr/local directory using the following command:

    sudo tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz
    
  3. We 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/bin
    
  4. Load the changes to the system using the following command:

    source /etc/profile.d/go.sh
    
  5. Verify 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:

  1. 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.zip
    
  2. Extract the downloaded file to the '/opt' directory using the following command:

    sudo unzip -d /opt gotify-linux-amd64.zip
    
  3. Create a new system user to run the Gotify server.

    sudo useradd --home-dir /var/lib/gotify --shell /usr/sbin/nologin --system gotify
    
  4. Change the ownership of the '/opt/gotify' directory to the newly created 'gotify' user.

    sudo chown -R gotify:gotify /opt/gotify
    
  5. Create a new systemd service file to control the Gotify server using the following command:

    sudo vi /etc/systemd/system/gotify.service
    

    Copy 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.target
    
  6. Reload the systemd system.

    sudo systemctl daemon-reload
    
  7. Start the Gotify service and enable it to start automatically at system boot.

    sudo systemctl enable --now gotify
    
  8. Verify 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.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!