Raspberry PI

Install and setup Gitea on Raspberry Pi

What is Gitea you ask. Gitea is a community managed lightweight code hosting solution written in Go. It is published under the MIT license. As well it is a self-hosted Git service, offering an interface much like Github for those who want to self-host their Git repositories but still want to be able to view them through a robust graphical interface.
The tutorial below will take you through all the steps to getting this set up.

I am running Ubuntu 22.4 on my Raspberry Pi 4 with 8GB of RAM. Before you start with installation of Gitea and all the configurations make sure you have installed and configured these packages:

  • Git
  • Maria-Server (MySql)
  • your OS is up to date

Now let’s get to the Gitea setup on your Raspberry Pi 4:

  • you will need to login to your MySQL (Maria-Server) and create user and database
1
2
3
4
CREATE DATABASE gitea;
GRANT ALL PRIVILEGES ON gitea.* TO 'gitea'@'localhost' IDENTIFIED BY 'ENTERPASSWORD';
FLUSH PRIVILEGES;
exit

Create an user that we will use to run Gitea on Raspberry Pi. This command will also create a folder for the user.

1
sudo adduser --disabled-login --gecos 'Gitea' git

These to option we have used:
–disabled-login as we do not want users login to the Raspberry Pi as this user
–gecos this allows us to set a name for the user, in our case to “Gitea”

Once we have set this up, we can now move to installation and configuration Gitea server.

  1. You need to switch to user git
  2. Change to home directory
  3. Create a directory gitea
  4. Navigate to the new directory gitea
  5. Download Gitea
  6. Make the download file executable
  7. You can now exit the git user
1
2
3
4
5
6
7
sudo su git
cd ~
mkdir gitea
cd gitea
wget https://dl.gitea.io/gitea/1.17.0/gitea-1.17.0-linux-arm-5 -O gitea
chmod a+x gitea
exit

In next step we have to create a file gitea.service

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

Once you have the file opened juts copy this into the file, you can leave the file as it is, no editing required.

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

[Service]
# Modify these two values ​​and uncomment them if you have
# repos with lots of files and get to HTTP error 500 because of that
###
# LimitMEMLOCK=infinity
# LimitNOFILE=65535
RestartSec=2s
Type=simple
User=git
Group=git
WorkingDirectory=/home/git/gitea
ExecStart=/home/git/gitea/gitea web
Restart=always
Environment=USER=git
HOME=/home/git

[Install]
WantedBy=multi-user.target

Press X and Y to save and in next step run last 2 commends to restart the services for Gitea

1
2
sudo systemctl enable gitea.service
sudo systemctl start gitea.service

These steps complete the installation and basic configuration of Gitea. If no errors and services are up and running, proceed to open your browser and enter IP address of the Raspberry Pi and port 3000 to complete the configuration of the Gitea server.
Open your browser and enter URL: https://RASPBERRYPI-IP:3000 — if your address 10.0.0.20 -> https:.//10.0.0.20:3000
You should see a configuration page for Gitea server where we will need to enter few details.

Under the Database setup you will need to enter the same password that you have setup for the gitea database for user gitea in beginning.

Gitea

  • Scroll down and under Domain, enter your IP address 10.0.0.20
  • Application URL change to http://10.0.0.20:3000/
  • Hit the Install Gitea button
  • It will take short moment and you should be redirected to your Gitea login page

Once the installation process has completed, your web browser will be redirected to the login page as shown below. Now all you have to do is register an account, then you will have Gitea up and running perfectly. Take some time to explore its interface and learn the ropes. If you are familiar with GitHub, you should be familiar with this.

Last steps create your Gitea account by clicking Need and Account? Sign up now. Once created, you can now create your repos and start developing.

Gitea

Happy development!

Leave a Reply