Need Assistance?

In only two hours, with an average response time of 15 minutes, our expert will have your problem sorted out.

Server Trouble?

For a single, all-inclusive fee, we guarantee the continuous reliability, safety, and blazing speed of your servers.

How to Install Gitea on Ubuntu 24.04 with MySQL 8

Gitea is a lightweight, self-hosted Git service similar to GitHub, GitLab, or Bitbucket. It offers a simple and fast way to manage your code repositories with a user-friendly web interface, issue tracking, code review etc, without the resource overhead. Gitea is ideal for individuals, small teams, or organizations that want full control over their codebase. In this guide, we’ll learn install Gitea on Ubuntu 24.04 and configure it with MySQL 8.

Prerequisites

  • Ubuntu 24.04 server
  • A user with root access or a user with sudo access
  • MySQL 8 installed

Steps to Install Gitea on Ubuntu 24.04

Step 1: Update the System

#apt update
#apt upgrade

Step 2: Install Required Packages

Install wget, Git and MariaDB/MySQL client tools:

#apt install git wget mysql-server

Step 3: Create Gitea Database and User in MySQL 8

Log into MySQL:

#mysql

Inside the MySQL prompt, run the following:

>CREATE DATABASE giteadb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

>CREATE USER 'git_user'@'localhost' IDENTIFIED BY 'StrongPasswordHere';

>GRANT ALL PRIVILEGES ON giteadb.* TO 'git_user'@'localhost';

>FLUSH PRIVILEGES;

>EXIT;

Step 4: Create a Dedicated Gitea User

#adduser --system --shell /bin/bash --gecos 'Git Version Control' --group --disabled-password --home /home/gituser gituser

Step 5: Download Gitea Binary

#wget -O gitea https://dl.gitea.io/gitea/latest/gitea-1.22.0-linux-amd64
#chmod +x gitea
#mv gitea /usr/local/bin/

Step 6: Create Required 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

Step 7: Create a systemd Service

Download the file to the “/etc/systemd/system/” directory

#wget https://raw.githubusercontent.com/go-gitea/gitea/main/contrib/systemd/gitea.service -P /etc/systemd/system/ 

Adjust the contents in the file gitea.service according to your username, file path etc.

Step 8: Enable and start Gitea:

#systemctl daemon-reexec
#systemctl enable --now gitea

Step 9: Finish Setup via Web UI

Now open your browser and go to:

http://your-server-ip:3000

Use the following configuration:

Database Settings:

Database Type: MySQL

Host: 127.0.0.1:3306

Username: git_user

Password: StrongPasswordHere

Database Name: giteadb

Application Settings:

Repository Root Path: /var/lib/gitea/data

Application URL: http://your-server-ip:3000/

Click Install Gitea to complete the setup.

Conclusion

You’ve now learned to install Gitea on Ubuntu 24.04 and configured it with MySQL 8 using a dedicated database and user. You’re ready to start self-hosting your own Git repositories!

If you encounter any challenges while setting up Gitea on Ubuntu 24.04 with MySQL 8, or simply prefer expert assistance to ensure a secure and optimized configuration, our team is here to help. We specialize in professional server management services tailored to your infrastructure needs.

Liked!! Share the post.

Get Support right now!

Start server management with our 24x7 monitoring and active support team

Let us know your requirement.

Can't get what you are looking for?

Get Support Right Away!

Thank You

We have received your query and will get back to you soon.