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:
- Upload your project in the user directory
- Enable bash/any preferred shell for the non root user from HestiaCP dashboard
- Do your application related configurations
- Create a systemd --user service if required
- Write a nginx template that will act as proxy to your applications port or unix socket
- 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
-
Create an user
-
Create a web domain
-
Create a mail domain
-
Create a mail account
-
Install SSL for web & mail domain
-
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.
- 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”
- 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.