Setup of a Gitea Git Server for the Lab
This post shows how to install a lightweight Gitea Git server on a RedHat Enterprise Linux VM. In my lab it holds the playbooks for the RedHat Ansible Automation Platform (AAP), but it can serve as the Git server for any other test setup as well.
Gitea is a single binary which we run as a systemd service. To keep things simple, the metadata is stored in SQLite, and the web interface and the Git access use plain HTTP on port 3000. In this example Gitea runs on the AAP VM (lin2, RHEL 9.7), but any other RHEL 9 or RHEL 10 VM works the same way. For a production installation we would put a reverse proxy with TLS in front of it and use PostgreSQL as the database.
Installing the Gitea Binary
The following steps need to be run as root. We look up the number of the latest Gitea release, download the binary and verify its checksum:
# install git and jq
dnf -y install git jq
# get the number of the latest Gitea release
GITEA_VERSION=$(curl -s https://dl.gitea.com/gitea/version.json | jq -r .latest.version)
echo $GITEA_VERSION
# download the binary and the checksum file and verify the binary
cd /tmp
curl -sLO https://dl.gitea.com/gitea/$GITEA_VERSION/gitea-$GITEA_VERSION-linux-amd64
curl -sLO https://dl.gitea.com/gitea/$GITEA_VERSION/gitea-$GITEA_VERSION-linux-amd64.sha256
sha256sum -c gitea-$GITEA_VERSION-linux-amd64.sha256
# install the binary
install -m 755 gitea-$GITEA_VERSION-linux-amd64 /usr/local/bin/gitea
gitea --version
Sample Output (click to expand):
[root@lin2 ~]# # install git and jq
dnf -y install git jq
# get the number of the latest Gitea release
GITEA_VERSION=$(curl -s https://dl.gitea.com/gitea/version.json | jq -r .latest.version)
echo $GITEA_VERSION
# download the binary and the checksum file and verify the binary
cd /tmp
curl -sLO https://dl.gitea.com/gitea/$GITEA_VERSION/gitea-$GITEA_VERSION-linux-amd64
curl -sLO https://dl.gitea.com/gitea/$GITEA_VERSION/gitea-$GITEA_VERSION-linux-amd64.sha256
sha256sum -c gitea-$GITEA_VERSION-linux-amd64.sha256
# install the binary
install -m 755 gitea-$GITEA_VERSION-linux-amd64 /usr/local/bin/gitea
gitea --version
Updating Subscription Management repositories.
Last metadata expiration check: 0:54:01 ago on Fri 04 Dec 2026 02:42:17 PM CET.
Package jq-1.6-21.el9_9.x86_64 is already installed.
Dependencies resolved.
=========================================================================================================================
Package Architecture Version Repository Size
=========================================================================================================================
Installing:
git x86_64 2.52.1-1.el9_9 rhel-9-for-x86_64-appstream-rpms 45 k
Installing dependencies:
git-core-doc noarch 2.52.1-1.el9_9 rhel-9-for-x86_64-appstream-rpms 3.2 M
perl-Error noarch 1:0.17029-7.el9 rhel-9-for-x86_64-appstream-rpms 46 k
perl-Git noarch 2.52.1-1.el9_9 rhel-9-for-x86_64-appstream-rpms 43 k
Transaction Summary
=========================================================================================================================
Install 4 Packages
Total size: 3.3 M
Total download size: 3.2 M
Installed size: 19 M
Downloading Packages:
[SKIPPED] perl-Error-0.17029-7.el9.noarch.rpm: Already downloaded
(2/4): git-2.52.1-1.el9_9.x86_64.rpm 92 kB/s | 45 kB 00:00
(3/4): git-core-doc-2.52.1-1.el9_9.noarch.rpm 3.6 MB/s | 3.2 MB 00:00
(4/4): perl-Git-2.52.1-1.el9_9.noarch.rpm 19 kB/s | 43 kB 00:02
-------------------------------------------------------------------------------------------------------------------------
Total 1.4 MB/s | 3.2 MB 00:02
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : git-core-doc-2.52.1-1.el9_9.noarch 1/4
Installing : perl-Error-1:0.17029-7.el9.noarch 2/4
Installing : git-2.52.1-1.el9_9.x86_64 3/4
Installing : perl-Git-2.52.1-1.el9_9.noarch 4/4
Running scriptlet: perl-Git-2.52.1-1.el9_9.noarch 4/4
Verifying : perl-Error-1:0.17029-7.el9.noarch 1/4
Verifying : git-2.52.1-1.el9_9.x86_64 2/4
Verifying : git-core-doc-2.52.1-1.el9_9.noarch 3/4
Verifying : perl-Git-2.52.1-1.el9_9.noarch 4/4
Installed products updated.
Installed:
git-2.52.1-1.el9_9.x86_64 git-core-doc-2.52.1-1.el9_9.noarch perl-Error-1:0.17029-7.el9.noarch
perl-Git-2.52.1-1.el9_9.noarch
Complete!
28.4.0
gitea-28.4.0-linux-amd64: OK
gitea version 28.4.0 built with go1.27.4
[root@lin2 tmp]#
Creating the OS User and the Directories
Gitea runs as the OS user git. The data is stored below /var/lib/gitea and the configuration in /etc/gitea:
# run as root
# create the OS user which runs Gitea
useradd --system --shell /bin/bash --comment 'Git Version Control' --create-home --home-dir /home/git git
# create the data and configuration directories
mkdir -p /var/lib/gitea/{custom,data,log}
chown -R git:git /var/lib/gitea
chmod -R 750 /var/lib/gitea
mkdir /etc/gitea
chown root:git /etc/gitea
chmod 770 /etc/gitea
Creating the Configuration
Instead of using the web-based installer we write the configuration file app.ini directly. The secrets are generated with the gitea binary, INSTALL_LOCK = true skips the installer page and DISABLE_REGISTRATION = true prevents that anybody can sign up:
# run as root
GITEA_HOST=$(hostname)
cat > /etc/gitea/app.ini <<EOF
APP_NAME = Gitea Lab
RUN_USER = git
RUN_MODE = prod
WORK_PATH = /var/lib/gitea
[server]
PROTOCOL = http
DOMAIN = $GITEA_HOST
HTTP_PORT = 3000
ROOT_URL = http://$GITEA_HOST:3000/
DISABLE_SSH = true
LFS_START_SERVER = false
[database]
DB_TYPE = sqlite3
PATH = /var/lib/gitea/data/gitea.db
[repository]
ROOT = /var/lib/gitea/data/gitea-repositories
DEFAULT_BRANCH = main
[security]
INSTALL_LOCK = true
SECRET_KEY = $(gitea generate secret SECRET_KEY)
INTERNAL_TOKEN = $(gitea generate secret INTERNAL_TOKEN)
[oauth2]
JWT_SECRET = $(gitea generate secret JWT_SECRET)
[service]
DISABLE_REGISTRATION = true
[log]
MODE = file
LEVEL = info
ROOT_PATH = /var/lib/gitea/log
EOF
chown root:git /etc/gitea/app.ini
chmod 660 /etc/gitea/app.ini
Creating and Starting the systemd Service
# run as root
cat > /etc/systemd/system/gitea.service <<'EOF'
[Unit]
Description=Gitea (Git with a cup of tea)
After=network.target
[Service]
Type=simple
User=git
Group=git
WorkingDirectory=/var/lib/gitea/
ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini
Restart=always
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea
[Install]
WantedBy=multi-user.target
EOF
# start Gitea and enable it at boot time
systemctl daemon-reload
systemctl enable --now gitea
systemctl status gitea --no-pager
# open the port in the firewall (currently we have disabled the firewall)
#firewall-cmd --permanent --add-port=3000/tcp
#firewall-cmd --reload
Sample Output (click to expand):
[root@lin2 tmp]# # run as root
cat > /etc/systemd/system/gitea.service <<'EOF'
[Unit]
Description=Gitea (Git with a cup of tea)
After=network.target
[Service]
Type=simple
User=git
Group=git
WorkingDirectory=/var/lib/gitea/
ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini
Restart=always
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea
[Install]
WantedBy=multi-user.target
EOF
# start Gitea and enable it at boot time
systemctl daemon-reload
systemctl enable --now gitea
systemctl status gitea --no-pager
# open the port in the firewall (currently we have disabled the firewall)
#firewall-cmd --permanent --add-port=3000/tcp
#firewall-cmd --reload
Created symlink /etc/systemd/system/multi-user.target.wants/gitea.service → /etc/systemd/system/gitea.service.
● gitea.service - Gitea (Git with a cup of tea)
Loaded: loaded (/etc/systemd/system/gitea.service; enabled; preset: disabled)
Active: active (running) since Fri 2026-12-04 16:42:34 CET; 20ms ago
Main PID: 30576 (gitea)
Tasks: 4 (limit: 100156)
Memory: 5.2M (peak: 5.2M)
CPU: 10ms
CGroup: /system.slice/gitea.service
└─30576 /usr/local/bin/gitea web --config /etc/gitea/app.ini
Dec 04 16:42:34 lin2.fritz.box systemd[1]: Started Gitea (Git with a cup of tea).
[root@lin2 tmp]#
Creating the Admin User
The name admin is reserved in Gitea, so we call the administrator gitadmin. As in the AAP installation, the password is simply password:
# run as root
sudo -u git /usr/local/bin/gitea admin user create --config /etc/gitea/app.ini --work-path /var/lib/gitea --username gitadmin --password password --email gitadmin@$(hostname) --admin --must-change-password=false
Sample Output (click to expand):
[root@lin2 tmp]# # run as root
sudo -u git /usr/local/bin/gitea admin user create --config /etc/gitea/app.ini --work-path /var/lib/gitea --username gitadmin --password password --email gitadmin@$(hostname) --admin --must-change-password=false
New user 'gitadmin' has been successfully created!
[root@lin2 tmp]#
Now we can log into the web interface with a URL similar to http://lin2.fritz.box:3000/.
Creating a Repository and Pushing the First Commit
A repository can be created in the web interface or with the Gitea REST API. As the user aap (the user we work with in the AAP posts) we create the repository aap-demo and push a first commit:
GITEA_URL=http://$(hostname):3000
# create the repository with the REST API
curl -s -u gitadmin:password -H 'Content-Type: application/json' -d '{"name":"aap-demo","private":false,"default_branch":"main"}' $GITEA_URL/api/v1/user/repos | jq -r .clone_url
# set the Git user name and email
git config --global user.name "gitadmin"
git config --global user.email "gitadmin@$(hostname)"
# store the credentials for the HTTP access (test environment only!)
git config --global credential.helper store
echo "http://gitadmin:password@$(hostname):3000" > ~/.git-credentials
chmod 600 ~/.git-credentials
# create the local repository and push it to Gitea
mkdir ~/aap-demo && cd ~/aap-demo
git init -b main
echo "# aap-demo - Playbooks for the AAP blog posts" > README.md
git add README.md
git commit -m "Initial commit"
git remote add origin $GITEA_URL/gitadmin/aap-demo.git
git push -u origin main
Sample Output (click to expand):
[root@lin2 tmp]# su - aap
Last login: Tue May 5 06:38:56 CEST 2026 from 11.1.1.174 on pts/1
[aap@lin2 ~]$ GITEA_URL=http://$(hostname):3000
# create the repository with the REST API
curl -s -u gitadmin:password -H 'Content-Type: application/json' -d '{"name":"aap-demo","private":false,"default_branch":"main"}' $GITEA_URL/api/v1/user/repos | jq -r .clone_url
# set the Git user name and email
git config --global user.name "gitadmin"
git config --global user.email "gitadmin@$(hostname)"
# store the credentials for the HTTP access (test environment only!)
git config --global credential.helper store
echo "http://gitadmin:password@$(hostname):3000" > ~/.git-credentials
chmod 600 ~/.git-credentials
# create the local repository and push it to Gitea
mkdir ~/aap-demo && cd ~/aap-demo
git init -b main
echo "# aap-demo - Playbooks for the AAP blog posts" > README.md
git add README.md
git commit -m "Initial commit"
git remote add origin $GITEA_URL/gitadmin/aap-demo.git
git push -u origin main
http://lin2.fritz.box:3000/gitadmin/aap-demo.git
Initialized empty Git repository in /home/aap/aap-demo/.git/
[main (root-commit) a318e33] Initial commit
1 file changed, 1 insertion(+)
create mode 100644 README.md
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 261 bytes | 261.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To http://lin2.fritz.box:3000/gitadmin/aap-demo.git
* [new branch] main -> main
branch 'main' set up to track 'origin/main'.
[aap@lin2 aap-demo]$
The repository is public, so the AAP automation controller can clone it without credentials. For private repositories we can create an access token and store it in a Source Control credential in AAP (run as root):
sudo -u git /usr/local/bin/gitea admin user generate-access-token --config /etc/gitea/app.ini --work-path /var/lib/gitea --username gitadmin --token-name aap --scopes all --raw
Have fun

Leave a Reply