Install Gitea Git Service on Debian 10 (Buster)

Gitea is the fastest and easiest self-hosted open source Git service. Gitea is written in Go and distributed as a binary package that runs on all platforms and architectures supported by Go-Linux, macOS, and Windows. In this guide, we will install and configure Gitea Git services on Debian 10 (Buster) Linux.

Gitea main features

  • Free and open source
  • Low resource usage-RAM and CPU
  • Multi-database support
  • Markdown and Orgmode support
  • Git Wiki integration
  • Repository token with write permissions
  • External git mirror
  • Git LFS 2.0
  • Fine-grained user roles (code, issues, wiki, etc.)
  • GPG signs commitment
  • Network code editor
  • Submit map
  • Issue search and issue tracker
  • Restrict push and merge access to certain users
  • Webhook support
  • Multiple LDAP / AD servers support
  • LDAP user synchronization
  • Two-factor certification (2FA)
  • OpenId Connect support
  • OAuth 2.0 integration (external authorization)
  • Most important / slackest integration
  • Microsoft Teams integration
  • External CI / CD status display
  • And many others

In this tutorial, we will install Gitea on Debian 10 (Buster) Linux and configure the Nginx proxy to forward requests to the Gitea internal service on the port. With Nginx, you can choose to terminate the SSL certificate when making security settings on Gitea on Debian 10 Server.

Step 1: Update your system and install git

You need to install git on your Debian machine. Let’s update the operating system and make sure git is installed.

sudo apt -y update
sudo apt -y install git vim bash-completion

View the installed Git version.

$ git --version
git version 2.20.1

Step 2: Add a git user account for Gitea

Gitea should have a dedicated local user account for administrative operations. Add users and groups to your Debian system by running the following command.

sudo adduser 
   --shell /bin/bash 
   --gecos 'Git Version Control' 
   --home /home/git 

User creation will assign users a unique ID and create their home directory.

Adding system user `git' (UID 108) ...
Adding new group `git' (GID 114) ...
Adding new user `git' (UID 108) with group `git' ...
Creating home directory `/home/git' ...

Step 3: Install MariaDB database server

The data will be stored on the MariaDB database server.

sudo apt -y install mariadb-server

Protect the database installation by setting a root password and deleting the test database and users.

$ sudo mysql_secure_installation 


In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Create a database for Gitea.

$ sudo mysql -u root -p

GRANT ALL PRIVILEGES ON gitea.* TO 'gitea'@'localhost' IDENTIFIED BY "[email protected]";

Step 4: Install Gitea on Debian 10 (Buster)

The gitea binary package can be found on the Downloads page. Please check the latest version before downloading.

export VER=1.9.4

Move the downloaded binary to /use/local/bin

chmod +x gitea-${VER}-linux-amd64
sudo mv gitea-${VER}-linux-amd64 /usr/local/bin/gitea

Confirm that the installation was successful by checking the installed version of Gitea.

$ gitea --version
Gitea version 1.9.4 built with GNU Make 4.1, go1.12.10 : bindata, sqlite, sqlite_unlock_notify

Step 5: Configure Systemd

Create the directories needed for Gitea settings.

sudo mkdir -p /etc/gitea /var/lib/gitea/{custom,data,indexers,public,log}
sudo chown git:git /var/lib/gitea/{data,indexers,log}
sudo chmod 750 /var/lib/gitea/{data,indexers,log}
sudo chown root:git /etc/gitea
sudo chmod 770 /etc/gitea

Web installer will need Write Rights profile /etc/gitea

Create a system service file for Gitea.

sudo vim /etc/systemd/system/gitea.service

Profile and setup user, Group And WorkDir.

Description=Gitea (Git with a cup of tea)

ExecStart=/usr/local/bin/gitea web -c /etc/gitea/app.ini
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea


Reload systemd and restart the Gitea service.

sudo systemctl daemon-reload
sudo systemctl enable --now gitea

Check service status.

$ systemctl status gitea
● gitea.service - Gitea (Git with a cup of tea)
   Loaded: loaded (/etc/systemd/system/gitea.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2019-10-20 07:37:06 UTC; 27s ago
 Main PID: 2637 (gitea)
    Tasks: 9 (limit: 4719)
   Memory: 93.8M
   CGroup: /system.slice/gitea.service
           └─2637 /usr/local/bin/gitea web -c /etc/gitea/app.ini

Oct 20 07:37:06 deb10 gitea[2637]: 2019/10/20 07:37:06 routers/init.go:74:GlobalInit() [T] Custom path: /var/lib/gitea/custom
Oct 20 07:37:06 deb10 gitea[2637]: 2019/10/20 07:37:06 routers/init.go:75:GlobalInit() [T] Log path: /var/lib/gitea/log
Oct 20 07:37:06 deb10 gitea[2637]: 2019/10/20 07:37:06 ...dules/setting/log.go:226:newLogService() [I] Gitea v1.9.4 built with GNU Make 4.1, go1.12
Oct 20 07:37:06 deb10 gitea[2637]: 2019/10/20 07:37:06 ...dules/setting/log.go:269:newLogService() [I] Gitea Log Mode: Console(Console:info)
Oct 20 07:37:06 deb10 gitea[2637]: 2019/10/20 07:37:06 ...les/setting/cache.go:42:newCacheService() [I] Cache Service Enabled
Oct 20 07:37:06 deb10 gitea[2637]: 2019/10/20 07:37:06 ...s/setting/session.go:45:newSessionService() [I] Session Service Enabled
Oct 20 07:37:06 deb10 gitea[2637]: 2019/10/20 07:37:06 routers/init.go:106:GlobalInit() [I] SQLite3 Supported
Oct 20 07:37:06 deb10 gitea[2637]: 2019/10/20 07:37:06 routers/init.go:37:checkRunMode() [I] Run Mode: Development
Oct 20 07:37:06 deb10 gitea[2637]: 2019/10/20 07:37:06 cmd/web.go:151:runWeb() [I] Listen:
Oct 20 07:37:06 deb10 gitea[2637]: 2019/10/20 07:37:06 ...ce/gracehttp/http.go:142:Serve() [I] Serving [::]:3000 with pid 2637

Step 6: Configure Nginx proxy

Install Nginx on Debian 10.

sudo apt -y install nginx

If ufw is enabled, http and https ports are allowed.

for i in http https; do
 sudo ufw allow $i

Create Nginx configuration file for Gitea

sudo vim /etc/nginx/conf.d/gitea.conf

Paste the following data into the created file.

server {
    listen 80;

    location / {
        proxy_pass http://localhost:3000;

Set the correct domain name and restart the Nginx service.

sudo systemctl restart nginx

Step 7: Complete Gitea installation from the web interface

After configuring Nginx proxy, access the Gitea web interface http: // server name / install

Setting up database authentication

On the first page, set up the database connection

Install Gitea Git Service on Debian 10 (Buster)

The username and password provided should match the username and password provided in the Database Configuration section. If the database server is on another host, Host section.

Set application general settings

Set up the SSH server domain-it should be the same domain used in the Nginx configuration.

Install Gitea Git Service on Debian 10 (Buster)

Provide the application URL and HTTP listening port. Since we are using Nginx proxy, there is no need to change the default value.

Install Gitea Git Service on Debian 10 (Buster)

Disable user self-registration

You can use the “Server and other service settings “. This means that an admin user will manually create a user account.

Install Gitea Git Service on Debian 10 (Buster)

You have the option to create an administrator user account. by default, root Users will automatically gain administrator access.

Install Gitea Git Service on Debian 10 (Buster)

When configuration is complete, click “Install Gitea” Button to complete the installation. After successful installation, you should log in to the Gitea Management Console.

Install Gitea Git Service on Debian 10 (Buster)

You have successfully installed Gitea on a Debian 10 (Buster) server. See Gitea documentation for advanced configuration and usage guides.

More git related guides.

How to install and configure GitLab CE on Debian 10 (Buster)