Post

Gitea ubuntu 24.04

Install Gitea on ubuntu 24.04

this instalation will be with a myslql lite database

  • first update the system
1
apt update && apt install git -y

Download gitea

  • use this link to download

  • or get the latest version from thare website

1
2
wget -O gitea https://dl.gitea.com/gitea/1.21.4/gitea-1.21.4-linux-amd64
chmod +x gitea

move the file

  • this command will move the file to the bin folder
1
mv gitea /usr/local/bin/gitea

Add permission

  • make the file executable
1
chmod +x /usr/local/bin/gitea

validate the installation

  • run the command to validate the installation
1
gitea --version

Create the user & group

  • –system: Designates the user as a system user

  • –group: Creates a corresponding group for user

  • –disabled-password: Prevents password-based login for this user, enhancing security

  • –home /etc/gitea: Sets the user’s home director

1
adduser --system --group --disabled-password --home /etc/gitea gitea

Directory structure

  • make 3 directories

  • custom,data,log

  • the location /var/lib/gitea

1
mkdir -p /var/lib/gitea/{custom,data,log}

User mnagement

  • this is the 1 of 4 steps
1
chown -R gitea:gitea /var/lib/gitea/

User mnagement

  • this is the 2 of 4 steps
1
chmod -R 750 /var/lib/gitea/

User mnagement

  • this is the 3 of 4 steps
1
chown root:gitea /etc/gitea

User mnagement

    • this is the 4 of 4 steps
1
chmod 770 /etc/gitea

Add a Systemd Service

  • open a text editor vim or nano i will use nano

  • sudo nano /etc/systemd/system/gitea.service

  • past and save

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
[Unit]
Description=Gitea (Git with a cup of tea)
After=syslog.target
After=network.target

[Service]
# Uncomment the next line if you have repos with lots of files and get a HTTP 500 error because of that
# LimitNOFILE=524288:524288
RestartSec=2s
Type=notify
User=gitea
Group=gitea
#The mount point we added to the container
WorkingDirectory=/var/lib/gitea
#Create directory in /run
RuntimeDirectory=gitea
ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini
Restart=always
Environment=USER=gitea HOME=/var/lib/gitea/data GITEA_WORK_DIR=/var/lib/gitea
WatchdogSec=30s
#Capabilities to bind to low-numbered ports
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_BIND_SERVICE

[Install]
WantedBy=multi-user.target


Restart the service

  • to make the changes let us restart the service
1
systemctl daemon-reload

Start gitea

  • this will start gitea on port 3000
1
systemctl enable --now gitea

Using gitea

  • change the place-here with the machine ip

  • you can use the ip of the machine or the domain name

1
http://place-here:3000

This post is licensed under CC BY 4.0 by the author.