Gitea is an open-source forge software package that allows you to host software development version control using Git. It also offers collaborative features such as bug tracking, wikis, and code review. In this guide, we will walk you through the process of installing Gitea on Rocky Linux 9.
Prerequisites
Before we begin, make sure you have the following prerequisites:
- Rocky Linux 9 installed
- Full SSH root access
Gitea supports various databases, including SQLite, PostgreSQL, MySQL, MariaDB, TiDB, and MSSQL. In 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
You can check the version of SQLite by running the following command:
sqlite3 --version
The output should display the version number, confirming that SQLite is successfully installed.
Install Git
Next, we need to install Git, which is a version control system. Use the following command to install Git:
dnf install git
To verify the installation and check the version of Git, run the following command:
git --version
The output should display the version number, indicating that Git is installed correctly.
Create a User for Git
We will now create a user that will run the Git application. Execute the following command to add the user:
adduser --system --shell/bin/bash --comment 'Git Version Control' --create-home --home/home/git git
Download the Gitea Binary
Gitea is a self-hosted Git service that offers features similar to GitHub, Bitbucket, or GitLab. To download the Gitea binary, follow these steps:
- Visit theGitea download page and locate the latest version available.
- Use the
wget
command to download the Gitea binary. ReplaceVERSION
with the desired version number:
wget -O /tmp/gitea https://dl.gitea.com/gitea/VERSION/gitea-VERSION-linux-amd64
For example, if the latest version is 1.18.3, the command would be:
wget -O /tmp/gitea https://dl.gitea.com/gitea/1.18.3/gitea-1.18.3-linux-amd64
- Move the downloaded Gitea binary to the
/usr/local/bin
directory:
mv /tmp/gitea /usr/local/bin/gitea
- Make the binary executable:
chmod +x /usr/local/bin/gitea
Configure Gitea Directories and Permissions
To prepare the directory structure for Gitea and set the required permissions and ownership, follow these steps:
- Create the necessary directories:
mkdir -p /var/lib/gitea/{custom,data,indexers,public,log}
- Set ownership of the directories:
chown git: /var/lib/gitea/{data,indexers,log}
- Set permissions for the directories:
chmod 750 /var/lib/gitea/{data,indexers,log}
- Create the
/etc/gitea
directory:
mkdir /etc/gitea
- Set ownership of the directory:
chown root:git /etc/gitea
- Set permissions for the directory:
chmod 770 /etc/gitea
To give the proper file permission, use the following command:
restorecon -rv /usr/local/bin/gitea
Create a Systemd Unit File
To ensure Gitea runs as a service, we need to create a Systemd unit file. Follow these steps:
- Download the unit file using the following command:
wget https://raw.githubusercontent.com/go-gitea/gitea/master/contrib/systemd/gitea.service -P /etc/systemd/system/
- Reload the Systemd daemon to apply the changes:
systemctl daemon-reload
- Enable and start the Gitea service:
systemctl enable --now gitea
To check the status of the Gitea service, use the following command:
systemctl status gitea
If everything is set up correctly, the output should indicate that the Gitea service is active and running.
Configure Gitea
Now that Gitea is installed and running, we need to configure it. Follow these steps:
- Allow the Gitea port (default: 3000) through the firewall:
firewall-cmd --permanent --zone=public --add-port=3000/tcp firewall-cmd --reload
- Open your browser and navigate to
http://yourserver-ip-address:3000
to access the Gitea application. - Follow the on-screen instructions to complete the Gitea setup.
During the setup, you will need to provide the following information:
- Database Type: Select SQLite3.
- Database Path: Use an absolute path, for example:
/var/lib/gitea/data/gitea.db
. - Application General Settings: Enter the required details, such as Site Title, Repository Root Path, Git LFS Root Path, Run As Username, SSH Server Domain, SSH Port, Gitea HTTP Listen Port, Gitea Base URL, and Log Path.
- Click on “Install” to complete the Gitea installation.
Create the First User
Once the installation is complete, you can create the first user for Gitea. Follow these steps:
- Open
http://yourip:3000/user/sign_up
in a web browser. - Fill in the required details, including username, email, and password.
- Submit the form to create the user.
Congratulations! You have successfully installed and configured Gitea on Rocky Linux 9. You can now start using Gitea to host your software development projects and collaborate with your team.
For reliable and scalable cloud hosting solutions, consider Shape.host. They offer Linux SSD VPS services that are perfect for hosting Gitea and other applications. With Shape.host, you can trust in their expertise and enjoy efficient, secure, and cost-effective hosting solutions.
Remember to regularly update Gitea and follow best practices for security and maintenance. Happy coding!