We have most of the prerequisites installed for gitea, and we could download the binary and run it as we are, but we want this to be a daemon (a process that runs in the background, and doesn’t need an interactive shell open to run in) so we need to create a system user for it, and set it up as a service. We will also need to create the config files, and directory structure that Gitea expects. (most of the following is taken from the documentation at Gitea’s documentation pages with a few minor tweaks)

sudo apt-get install git
sudo adduser \
     --system \
     --shell /bin/bash \
     --gecos 'Git Version Control' \
     --group \
     --disabled-password \
     --home /var/lib/gitea \
     git
sudo mkdir -p /var/lib/gitea/{custom,data,indexers,public,log}
sudo chown git:git /var/lib/gitea/{data,indexers,log}
sudo chown git:git /var/lib/gitea
sudo chmod 750 /var/lib/gitea/{data,indexers,log}
sudo mkdir /etc/gitea
sudo chown root:git /etc/gitea
sudo chmod 770 /etc/gitea
wget -O gitea https://dl.gitea.io/gitea/1.13.0/gitea-1.13.0-linux-amd64
sudo chown root:root gitea
sudo mv gitea /usr/local/bin/
sudo chmod +x /usr/local/bin/gitea
sudo -u git /usr/local/bin/gitea web -c /etc/gitea/app.ini

At this point you should be able to visit your git domain in a web browser, https://git.example.com in this guide, and configure gitea through the installation page.

Most of the settings can be left as their defaults, with the following exceptions,

  • In Database settings you need to enter the Database password you set for the gitea user of the database
  • In General Application Settings change the LFS Root Path to “/var/lib/gitea/data/lfs”
  • Change Domain to the FQDN you are using (git.example.com in this guide)
  • Change Application URL to HTTPS at your domain (https://git.example.com/ in this guide)
  • Change Log Path to “/var/lib/gitea/log”
  • In the Optional Settings, expand Email Service Settings and set SMTP Host to “localhost:25”
  • Set From to something like “no-reply@git.example.com”
  • Tick both Enable Register Confirmation and Enable Mail Notifications

The remaining Settings are your choice, click install Gitea and the config file will be created and Gitea will be configured. Once done the gitea process will stop, and we need to make the config secure.

sudo chmod 750 /etc/gitea
sudo chmod 644 /etc/gitea/app.ini

We now have a configured Git server, there just remain a few steps to get it ready to go into service.