‍Gitea is an open-source forge software package that provides a complete solution for hosting software development version control using Git. It also offers collaborative features like bug tracking, wikis, and code review. In this article, we will guide you through the process of installing Gitea on Rocky Linux 9, a popular Linux distribution.

Prerequisites

Before we begin, make sure you have the following prerequisites:

  • Rocky Linux 9 installed
  • Full SSH root access

Gitea supports multiple databases, including SQLite, PostgreSQL, MySQL, MariaDB, TiDB, and MSSQL. For this guide, we will use SQLite as the database for Gitea. However, you can choose any of the supported databases based on your requirements.

To install SQLite, use the following command:

dnf install sqlite

To check the version of SQLite, run the following command:

sqlite3 --version

The output should display the installed version of SQLite.

Install Git

Git is a version control system that is essential for Gitea. To install Git, use the following command:

dnf install git

To check the version of Git, run the following command:

git --version

Make sure that Git is successfully installed by verifying the output.

Create a User for Git

Next, we need to create a user that will run the Git application. Use the following command to add the user:

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

This command creates a system user named “git” with the necessary settings for running Git.

Download the Gitea Binary

Now, let’s download the Gitea binary from the official Gitea website. At the time of writing this article, the latest version of Gitea is 1.18.3. However, make sure to check the download page for the most recent version.

Use the following command to download the Gitea binary:

dnf install wget
wget -O /tmp/gitea https://dl.gitea.com/gitea/1.18.3/gitea-1.18.3-linux-amd64

This command downloads the Gitea binary and saves it in the “/tmp” directory.

Move the Gitea Binary

Once the Gitea binary is downloaded, we need to move it to the “/usr/local/bin” directory. Use the following command:

mv /tmp/gitea /usr/local/bin

This command moves the Gitea binary to the appropriate location.

Set Permissions and Ownership

To ensure that Gitea has the correct permissions and ownership, we need to create the necessary directory structure and set the appropriate settings.

Use the following commands to 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

These commands create the required directories and set the permissions and ownership accordingly.

Create a Systemd Unit File

Next, we need to create a Systemd unit file for Gitea. This file defines how Gitea should be managed by the system. Use the following command to download the unit file:

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

This command downloads the unit file and saves it in the “/etc/systemd/system” directory.

Reload and Enable Gitea Service

Once the unit file is in place, we need to reload the Systemd daemon and enable the Gitea service to ensure that it starts automatically on system boot.

Use the following commands to reload and enable the Gitea service:

systemctl daemon-reload
systemctl enable --now gitea

The first command reloads the Systemd daemon, and the second command enables the Gitea service.

Check the Status of Gitea Service

To verify that Gitea is running correctly, you can check the status of the Gitea service. Use the following command:

systemctl status gitea

The output should display the status of the Gitea service, indicating whether it is active and running.

Configure Gitea

Now that Gitea is installed and running, it’s time to configure it according to your needs. To do this, you need to access the Gitea application through your web browser.

Open your browser and enter the following URL, replacing “yourserver-ip-address” with the actual IP address of your server:

http://yourserver-ip-address:3000

This will take you to the Gitea setup page. Follow the on-screen instructions to complete the setup process.

During the setup, you will need to provide the following information:

  • Database Type: Select SQLite3.
  • Path: Use an absolute path, such as “/var/lib/gitea/data/gitea.db”.
  • Site Title: Enter a title for your Gitea instance.
  • Repository Root Path: Keep the default value “/home/git/gitea-repositories”.
  • Git LFS Root Path: Keep the default value “/var/lib/gitea/data/lfs”.
  • Run As Username: Enter “git”.
  • SSH Server Domain: Enter your domain name or server IP address.
  • SSH Port: Use the default port, 22, or specify a different port if needed.
  • Gitea HTTP Listen Port: Keep the default port, 3000.
  • Gitea Base URL: Use “http” followed by your domain or server IP address.
  • Log Path: Keep the default value “/var/lib/gitea/log”.

Once you have entered all the required information, click on the “Install” button to complete the Gitea setup.

Create the First User

After the installation is complete, you can create the first user for your Gitea instance. Open your web browser and enter the following URL, replacing “yourip” with the IP address of your server:

http://yourip:3000/user/sign_up

This will take you to the user registration page. Fill in the required details and submit the form to create your Gitea account.

Conclusion

Congratulations! You have successfully installed Gitea on Rocky Linux 9. You can now use Gitea to host your software development projects and collaborate with your team. Gitea provides a user-friendly interface and offers powerful features for version control, bug tracking, wikis, and code review.

If you’re looking for reliable and scalable cloud hosting solutions, Shape.host offers Linux SSD VPS services that can meet your needs. Shape.host provides efficient and secure hosting solutions, allowing you to focus on your development projects without worrying about infrastructure management.