Creating a gitea service

Updated on 28 Dec 2018

The instructions for creating a service for Gitea are also applicable for other services.

Create the service file

In the /etc/systemd/system directory, create a file called gitea.service.


Description=Gitea (Git with a cup of tea)

# Modify these two values and uncomment them if you have
# repos with lots of files and get an HTTP error 500 because
# of that
ExecStart=/var/lib/gitea/gitea web -c /etc/gitea/app.ini
Environment=USER=brent HOME=/mnt/git GITEA_WORK_DIR=/var/lib/gitea

# If you want to bind Gitea to a port below 1024 uncomment
# the two values below


Some of these settings are fairly standard, infact you could almost copy it directly from the gitea.service sample, however there are some settings that we need to adjust for our purposes. In particular

  • User
  • Group
  • WorkingDirectory
  • ExecStart
  • Environment, HOME

Another item that I added was at the start, After=mysqld.service because my version of gitea was installed with MySQL.

Enabling and starting the Service

Once we have created the service file, the service needs to be enabled. enable means that the service will automatically start at boot.

sudo systemctl enable gitea
sudo systemctl start gitea

Notice that the first line in the screen shot, also corresponds with the Description in our gitea.service file we created in the earlier section.