[Tutorial] Install Gitea/any kind of web application with HestiaCP

This was in draft for long time due to editing. I am finally releasing without any second thought.

Things are pretty basic with any types of web application:

  1. Upload your project in the user directory
  2. Enable bash/any preferred shell for the non root user from HestiaCP dashboard
  3. Do your application related configurations
  4. Create a systemd --user service if required
  5. Write a nginx template that will act as proxy to your applications port or unix socket
  6. Restart nginx and your applications systemd service

In this tutorial I will show how you can install Gitea with HestiaCP. Gitea is an open source self hosted alternative for GitHub written in Go. If you can understand the basics you can adapt and install any web application you wish and serve it with HestiaCP.

I am going to use CLI commands from HestiaCP. If you wish you can use the web UI.

Part 1: Basic user & domain configuration

  1. Create an user

  2. Create a web domain

  3. Create a mail domain

  4. Create a mail account

  5. Install SSL for web & mail domain

  6. Enable bash or any preferred shell for the user from HestiaCP dashboard

Part 2: Enabling systemd --user instance for the user

Systemd --user docs: systemd/User - ArchWiki.

  1. Add following lines to users .bashrc / .zsh file

export XDG_RUNTIME_DIR=“/run/user/$UID”
export DBUS_SESSION_BUS_ADDRESS=“unix:path=${XDG_RUNTIME_DIR}/bus”

  1. Enable lingering for the user

loginctl enable-linger example user

Now you can reboot your system to prepare a systemd --user instance for this user on boot.

Now you can create example systemd --user service in users home directory on the /home/exampleuser/.config/systemd/user/ directory.

You will be able to do everything as normal user and you won’t need to do sudo for systemd --user
E.g : systemctl --user start myservice

Part 3. Installing Gitea and systemd --user service for Gitea

We will need a MySQL database for the Gitea instance. You can do that from the web UI.

We will now download the Gitea binary and start it using a systemd service.
You can refer to Gitea docs for Gitea installation procedure:

Part 4: Modify Nginx template & restart Nginx

If you want to do this permanently you will need to create a Nginx template. Before creating a template you might want to try out the config. The config will be in /home/username/conf/web/domain.com/ . Config files are nginx.conf & nginx.ssl.conf

After you’re done simply restart Nginx with “systemctl restart nginx” and enjoy.

1 Like

As I am new user in forum I can’t post more than two links so here is other doc links.

Sample service file: gitea-quick-installer/gitea.service at master · istiak101/gitea-quick-installer · GitHub

Remove the user and group from the file as that is not required for systemd --user services.

HestiaCP web template docs:
https://docs.hestiacp.com/admin_docs/web.html#how-do-web-templates-work