From the moment I heard about gitea I knew I wanted to try it. It’s a self-hosted Git service which means all the knowlege, repos, and accounts are in my hands. Just a step away from requiring an internet connections to handle my git repos.
Table of contents
Open Table of contents
My Use Case
For me, I wanted to have a git service that was different than the big names of GitHub and GitLab. I didn’t want to even touch the solution offered by Atlassian (I still have nightmares with that). I don’t need all the fancy bells and whistles. Gitea offers a low bar for requirements and is not resource intensive.
The following is the first steps I have taken to getting Gitea to run on my local network at home.
Steps
I decided to, yet again, use Pop!_OS as my OS. The system I am running is a cheap mini computer that my husband picked up for me off Amazon so I can play around and test things. It has 16GBs memory and 3.4 Intel N95 CPU. Nothing big, nor fancy… yet.
Database: MariaDB
My chosen database for this solution is MariaDB.
1. Install MariaDB and secure it
# Make sure repos are up to date
sudo apt update
# Get MariaDB
sudo apt install mariadb-server
# One finished secure that install
sudo mysql_secure_installation
# Verify status of database server
sudo systemctl status mariadb
# If not running, start it
sudo systemctl start mariadb
2. Setting up database user account for Gitea
# Connect to the database; by default using unix_sockets
sudo mariadb
-- Create database for gitea
CREATE DATABASE gitea;
-- Create gitea user and set a nice password for it.
GRANT ALL PRIVILEGES ON gitea.* to 'gitea'@'localhost' IDENTIFIED BY 'CrazyFunPasswordOrSomething';
-- Flush to ensure new privileges take
FLUSH PRIVILEGES;
-- Leave once done!
exit;
3. Set up system user for git
sudo adduser --system --shell /bin/bash --group --disabled-password --home /home/git git
Keep in mind, this is a local network install and will never be accessible outside of the local network.
4. Install Gitea
Head over to https://dl.gitea.com/gitea and look for the version that you want to use for your distro/system. This is what I did (there are many other options for this part, but this is what I did):
# Grab the image
wget https://dl.gitea.com/gitea/1.21.5/gitea-1.21.6-linux-amd64
# Copy image to new location
cp gitea-1.21.6-linux-amd64 /user/bin/gitea
# Modify all the permissions and create new directories for use
sudo chmod 755 /usr/bin/gitea
sudo mkdir -p /etc/gitea /var/lib/gitea/{custom,data,indexers,public,log}
sudo chown git:git /etc/gitea /var/lib/gitea/{custom,data,indexers,public,log}
sudo chmod 750 /var/lib/gitea/{data,indexers,log}
sudo chmod 770 /etc/gitea
5. Create Gitea Service
# create file and edit it
vim /etc/systemd/system/gitea.service
The contents of gitea.service
:
[Unit]
Description=Gitea
After=syslog.target
After=network.target
[Service]
RestartSec=3s
Type=simple
User=git
Group=git
WorkingDirectory=/var/lib/gitea
ExecStart=/user/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
# Reload daemon and start service
systemctl daemon-reload
systemctl start gitea
systemctl enable gitea
6. Connect and finish install
Using a browser head to http://IPADDRESS:3000
and finish the installation. There are several options you can set and configure.
Note that this is http
and not https
and I do not mention ufw
. That’s
the next article I’ll be working to give a proper hostname and using SSL. I
just wanted to see if I could get it running.