RHEL BasedRocky Linux

How To Install Gitea on Rocky Linux 9

Install Gitea on Rocky Linux 9

In this tutorial, we will show you how to install Gitea on Rocky Linux 9. For those of you who didn’t know, Gitea is a free and open-source Git repository hosting platform. It allows you to work with version control software with other features including issue tracking, pull requests, user management, notifications, and more. It is very similar to GitHub. Gitea is written in the Go language and can be installed on multiple operating systems, including Linux, macOS, Windows, and architectures like amd64, i386, ARM, and others.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of Gitea on Rocky Linux. 9.


  • A server running one of the following operating systems:  Rocky Linux 9.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Gitea on Rocky Linux 9

Step 1. The first step is to update your system to the latest version of the package list. To do so, run the following commands:

sudo dnf makecache --refresh
sudo dnf install dnf-utils

Step 2. Install MariaDB Database.

By default, MariaDB is available on Rocky Linux 9 base repository. Now run the following command below to install the latest stable version of MariaDB to your system:

sudo dnf install mariadb-server mariadb

Once the installation is complete, start the MariaDB service and enable it to automatically start on boot by running the following command below:

sudo systemctl enable mariadb --now
sudo systemctl start mariadb
sudo systemctl status mariadb

To check the version of MariaDB installed, run the command below:

mariadb --version

By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation script. you should read and below each step carefully which will set a root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MariaDB:


Configure it like this:

- Set root password? [Y/n] y
- Remove anonymous users? [Y/n] y
- Disallow root login remotely? [Y/n] y
- Remove test database and access to it? [Y/n] y
- Reload privilege tables now? [Y/n] y

Next, you will need to create a database and user for Gitea:

mysql -u root -p

Once you are logged in, create a database and user with the following command:

MariaDB [(none)]> CREATE DATABASE gitea CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_unicode_ci';
MariaDB [(none)]> GRANT ALL ON gitea.* TO 'gitea'@'localhost' IDENTIFIED BY 'your-strong-password';
MariaDB [(none)]> EXIT;

For additional resources on installing MariaDB, read the post below:

Step 2. Installing Git.

By default, Git is available on Rocky Linux 9 base repository. Now run the following command below to install the stable version of Git to your system:

sudo dnf install git

You can verify the installed version by using the command below:

git --version

Next, add the user that will run the Git application:

adduser --system --shell /bin/bash --comment 'Git Version Control' --create-home --home /home/git git

For additional resources on installing Git, read the post below:

Step 3. Installing Gitea on Rocky Linux 9.

By default, Gitea is not available on the Rocky Linux 9 base repository. Simply download the latest version of the Gitea package by using the wget command:

wget -O /tmp/gitea https://dl.gitea.io/gitea/1.17.3/gitea-1.17.3-linux-amd64

Move the Gitea binary file to “/usr/local/bin“:

mv /tmp/gitea /usr/local/bin

Next, make the binary executable:

chmod +x /usr/local/bin/gitea

Now 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 give the file permission using the following command:

restorecon -rv /usr/local/bin/gitea

Step 4. Create a Systemd Service File for Gitea.

We will need to create a systemd service file to manage the Gitea service:

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

Then, reload the systemd daemon with the following command:

sudo systemctl daemon-reload
sudo systemctl enable --now gitea

Step 5. Configure Firewall.

Rocky Linux 9 comes with firewalld enabled by default, and it will block other connections from other computers that are trying to access our Gitea service. We must open the appropriate ports so that the Gitea resources can be accessed from other machines:

sudo firewall-cmd --permanent --zone=public --add-port=3000/tcp
sudo firewall-cmd --reload

Step 6. Accessing Gitea Web Interface.

Once successfully installed, open your web browser and access the Gitea Web UI using the URL http://your-IP-address:3000. You will be redirected to the following page:

Install Gitea on Rocky Linux 9

Congratulations! You have successfully installed Gitea. Thanks for using this tutorial for installing Gitea on your Rocky Linux 9 system. For additional help or useful information, we recommend you check the official Gitea website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!


r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button