How to Install Gitea on Ubuntu 22.04
Gitea is an open-source forge software package for hosting software development version control using Git as well as other collaborative features like bug tracking, wikis, and code review.
Prerequisites
- Full SSH root access or a user with Sudo privileges is required.
- Gitea supports the following databases.
- SQLite
- PostgreSQL
- MySQL
- MariaDB
In our guide below, we’ll use SQLite as the database for Gitea. You can pick any of the supported databases in your installation as needed.
To Install SQLite using the following command,
apt install sqlite3
To check the version,
sqlite3 --version
Output:
root@crown:~# sqlite3 --version
3.37.2 2022-01-06 13:25:41 872ba256cbf61d9290b571c0e6d82a20c224ca3ad82971edc46b29818d5dalt1
Install Git
Gitea is a painless self-hosted Git service. With features similar to ones in GitHub, Bitbucket, or GitLab.
Git is the standard for distributed version control systems and can be installed on Ubuntu systems using apt
.
Check for system updates and install them.
apt update
apt upgrade
Install the Git package using the following command,
apt install git
You can check the version of Git installed with the following command,
git --version
Output:
root@crown:~# git --version
git version 2.34.1
Create a Git user,
sudo adduser \
--system \
--shell /bin/bash \
--gecos 'Git Version Control' \
--group \
--disabled-password \
--home /home/git \
git
Download the Gitea binary
Download the Gitea binary from download page and make it executable.
apt install wget
wget -O /tmp/gitea https://dl.gitea.io/gitea/1.16.7/gitea-1.16.7-linux-amd64
Output:
root@crown:~# wget -O /tmp/gitea https://dl.gitea.io/gitea/1.16.7/gitea-1.16.7-linux-amd64
--2022-05-11 06:56:11-- https://dl.gitea.io/gitea/1.16.7/gitea-1.16.7-linux-amd64
Resolving dl.gitea.io (dl.gitea.io)... 104.26.0.119, 172.67.74.188, 104.26.1.119, ...
Connecting to dl.gitea.io (dl.gitea.io)|104.26.0.119|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 107556952 (103M) [application/octet-stream]
Saving to: ‘/tmp/gitea’
Move the Gitea binary file to /usr/local/bin
.
mv /tmp/gitea /usr/local/bin
Make the binary executable.
chmod +x /usr/local/bin/gitea
Create the directory structure and set the required permissions and ownership.
mkdir -p /var/lib/gitea/{custom,data,indexers,public,log}
chown git: /var/lib/gitea/{data,indexers,log}
chmod 750 /var/lib/gitea/{data,indexers,log}
mkdir /etc/gitea
chown root:git /etc/gitea
chmod 770 /etc/gitea
To create a Systemd Unit File.
Download the file to the "/etc/systemd/system/" directory using the following command.
wget https://raw.githubusercontent.com/go-gitea/gitea/main/contrib/systemd/gitea.service -P /etc/systemd/system/
To reload and enable the Gitea service,
systemctl daemon-reload
systemctl enable --now gitea
Output:
root@crown:~# systemctl enable --now gitea
Created symlink /etc/systemd/system/multi-user.target.wants/gitea.service → /etc/systemd/system/gitea.service.
To check the status of the Gitea service,
systemctl status gitea
Output:
root@crown:~#systemctl status gitea
● gitea.service - Gitea (Git with a cup of tea)
Loaded: loaded (/etc/systemd/system/gitea.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2022-03-22 15:59:38 UTC; 3h 12min ago
Main PID: 3126 (gitea)
Tasks: 7 (limit: 1074)
Memory: 112.8M
CPU: 16.122s
CGroup: /system.slice/gitea.service
└─3126 /usr/local/bin/gitea web --config /etc/gitea/app.ini
Configure Gitea
If you're running ufw
firewall on your server, allow the port 3000
ufw allow 3000/tcp
Navigate to your browser. http://yourserver-ip-address:3000 to access the Gitea dashboard.
Follow the on-screen instructions to complete the Gitea setup. Click on Register to start the database initialization.
Database Settings:
- Database Type: SQLite3
- Path: Use an absolute path,
/var/lib/gitea/data/gitea.db
Application General Settings:
- Site Title: Enter username.
- Repository Root Path: keep the default /home/git/gitea-repositories.
- Git LFS Root Path: keep the default /var/lib/gitea/data/lfs.
- Run As Username: git
- SSH Server Domain: Enter your domain name or your IP address.
- SSH Port: 22, change it if SSH is listening on other Port
- Gitea HTTP Listen Port: 3000
- Gitea Base URL: Use http with your domain name or server IP address.
- Log Path: Leave the default /var/lib/gitea/log
Click on Install to Install Gitea.
Once the installation is completed then create the first user. Open http://yourip:3000/user/sign_up in a web browser and fill in the required details.
Once the form has been submitted, you are logged into your Gitea account.
Upgrading Gitea
To upgrade to a new version first stop the Gitea service.
To stop the Gitea service.
systemctl stop gitea
Download the Gitea binary from download page.
At the time of writing this article, the latest Gitea version is 1.16.7 If there is a newer version available on the link above, change the VERSION variable before using the following command.
VERSION=<THE_LATEST_GITEA_VERSION>
wget -O /tmp/gitea https://dl.gitea.io/gitea/${VERSION}/gitea-${VERSION}-linux-amd64
Move the Gitea binary file to /usr/local/bin
and make the binary executable.
mv /tmp/gitea /usr/local/bin
chmod +x /usr/local/bin/gitea
To restart the Gitea service,
systemctl restart gitea
Done.
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME
for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS