Gitea Git Service on FreeBSD - Installation and Configuration

Gitea is a free, lightweight, universal and official Open Source system. Gitea covers Git hosting, team collaboration, CI/CD and code review. Gitea is written in Go and is a community-based, lightweight code hosting solution published under the MIT license. Not only that, Gitea can manage Git repositories, supports authentication via third-party services, including Oauth, which allows you to use Casdoor for authentication. This is a fork of another lightweight system, namely Gogs.

Gitea as a fork of Gogs was developed on October 17, 2016 by people who were tired of the restrictions in Git repository development. The Gitea system is indispensable for developers to organize all work related to Git repositories. With your own private server, Gitea can be deployed as a service similar to GitHub and other services on your hardware.

Gitea has advantages that other software does not have, among the advantages of Gitea that you should know include:
  1. Compactness - Can be run on low-spec hardware, but its functionality is not affected and remains quite extensive.
  2. User friendly and easy to use interface.
  3. Integration - Can be connected to social media platforms such as Discord, Linkedin and others.
  4. Installation and configuration are very easy and can also be run on almost all operating systems such as Windows, BSD, Linux and MacOS.

1. Gitea database

Gitea supports various databases, SQLite3, MySQL/MariaDB and PostgreSQL. This database will be used as a backend to store all information carried out by users. In this article, we will use SQLite3 as the database for Gitea. If your FreeBSD server does not have SQLite3 installed, you can run pkg install to install SQLite3.

Install SQLite3
root@ns3:~ # pkg install sqlite3
Check the SQLite version.

Check version
root@ns3:~ # sqlite3 --version
3.44.0 2023-11-01 11:23:50 17129ba1ff7f0daf37100ee82d507aef7827cf38de1866e2633096ae6ad8alt1 (64-bit)
The first step in installing Gitea is to install git and other dependencies that will form the library files.

Install dependencies
root@ns3:~ # pkg install go git git-lfs ca_root_nss openssl

2. Installation Gitea

Before installing Gitea, you must create users and groups for Gitea. We will create a user and group called "git" for Gitea. Run the command below to create a git user and group.

Create user & group
root@ns3:~ # pw add group git
root@ns3:~ # pw add user -n git -g git -s /sbin/nologin -c "user and group git"
After that, you can continue installing Gitea. On FreeBSD, the Gitea repository is available in the FreeBSD ports. Use the ports system to install Gitea.

root@ns3:~ # cd /usr/ports/www/gitea
root@ns3:/usr/ports/www/gitea # make install clean
In database, conf and log files, you provide file ownership rights and access rights.

Ownership and permissions
root@ns3:/usr/ports/www/gitea # chown -R git:git /var/db/gitea
root@ns3:/usr/ports/www/gitea # chown -R git:git /var/log/gitea
root@ns3:/usr/ports/www/gitea # chown -R git:git /usr/local/etc/gitea/conf
root@ns3:/usr/ports/www/gitea # chmod -R 775 /var/db/gitea
root@ns3:/usr/ports/www/gitea # chmod -R 775 /var/log/gitea

3. Gitea Configuration

The location of the Gitea configuration file is /usr/local/etc/gitea/conf, and the configuration file is named "app.ini". Open the file and edit the script to suit your system specifications. Below is an example of an "app.ini" script, which uses a SQLite3 database and a private IP address.

root@ns3:~ # ee /usr/local/etc/gitea/conf/app.ini
APP_NAME = Gitea: Git with a cup of tea
RUN_USER = git
RUN_MODE = prod

DB_TYPE  = sqlite3
HOST     =
NAME     = gitea
PATH     = /var/db/gitea/gitea.db
SSL_MODE = disable
USER     = root

ISSUE_INDEXER_PATH = /var/db/gitea/indexers/issues.bleve

ROOT_PATH = /var/log/gitea
MODE      = file
LEVEL     = Info

ENABLED = false

JWT_SECRET = D56bmu6xCtEKs9vKKgMKnsa4X9FDwo64HVyaS4fQ4mY

AVATAR_UPLOAD_PATH      = /var/db/gitea/data/avatars
DISABLE_GRAVATAR        = false

ROOT = /var/db/gitea/gitea-repositories
# Gitea's default is 'bash', so if you have bash installed, you can comment
# this out.

TEMP_PATH = /var/db/gitea/data/tmp/uploads

INTERNAL_TOKEN = 1FFhAklka01JhgJTRUrFujWYiv4ijqcTIfXJ9o4n1fWxz+XVQdXhrqDTlsnD7fvz7gugdhgkx0FY2Lx6IBdPQw==
SECRET_KEY   = ChangeMeBeforeRunning

PROVIDER_CONFIG = /var/db/gitea/data/sessions

DOMAIN       = localhost
HTTP_PORT    = 3000
ROOT_URL     =
DISABLE_SSH  = false
SSH_PORT     = 22
APP_DATA_PATH = /var/db/gitea/data

ENABLE_CAPTCHA         = true

4. Run Gitea

After that, you continue by running Gitea. Before you run Gitea, you must activate Gitea so that it can run automatically. Type the script below in the rc.conf file.

root@ns3:~ # ee /etc/rc.conf
Run Gitea with the service command.

root@ns3:~ # service gitea restart
To see the results, you can open Google Chrome, and type "", on your monitor screen it will appear as in the image below.

In this article, we have discussed what the Gitea installation process is and why Gitea is indispensable for many developers. Overall, Github and Gitea offer the best services for managing your software development projects. However, both have advantages and disadvantages, which you can consider depending on the type of work being done. Your experience and ability in using Git greatly influences which platform is right for your future project.
Iwan Setiawan

I Like Adventure: Mahameru Mount, Rinjani Mount I Like Writer FreeBSD

Post a Comment

Previous Post Next Post