Gitea is an open-source forge software package that facilitates software development version control using Git, along with other collaborative features like bug tracking, wikis, and code review. In this comprehensive guide, we will walk you through the step-by-step process of installing Gitea on AlmaLinux 9, a popular Linux distribution. Whether you are a developer or a business owner looking to streamline your software development workflow, Gitea offers a painless self-hosted Git service with features similar to those found in GitHub, Bitbucket, or GitLab.
Prerequisites
Before we begin the installation process, make sure you have the following prerequisites in place:
- AlmaLinux 9 installed
- Full SSH root access
Gitea supports various databases, including SQLite, PostgreSQL, MySQL, MariaDB, TiDB, and MSSQL. For this guide, we will be using SQLite as the database for Gitea. However, feel free to choose any of the supported databases based on your requirements.
To install SQLite, follow these steps:
- Install epel-release:
dnf install epel-release
- Install SQLite:
dnf install sqlite
To verify the installation, run the following command:
sqlite3 --version
You should see the version information similar to 3.34.1 2021-01-20 14:10:07
.
Installing Gitea
To install Gitea on AlmaLinux 9, follow these steps:
- Install Git:
dnf install git
To verify the installation, run the following command:
git --version
You should see the version information similar to git version 2.31.1
.
- Add a user for running the Gitea application:
adduser --system --shell /bin/bash --comment 'Git Version Control' --create-home --home/home/git git
- Download the Gitea binary:
wget -O /tmp/gitea https://dl.gitea.io/gitea/1.16.8/gitea-1.16.8-linux-amd64
Note: Replace
1.16.8
with the latest version available on the Gitea download page if necessary.
- Make the Gitea binary executable:
mv /tmp/gitea /usr/local/bin chmod +x /usr/local/bin/gitea
- Create the necessary directory structure and set permissions:
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
- Set file permissions:
restorecon -rv /usr/local/bin/gitea
- Create a Systemd unit file:
wget https://raw.githubusercontent.com/go-gitea/gitea/master/contrib/systemd/gitea.service -P /etc/systemd/system/
- Reload the Systemd service:
systemctl daemon-reload
- Enable and start the Gitea service:
systemctl enable --now gitea
To check the status of the Gitea service, run the following command:
systemctl status gitea
You should see output similar to the following:
● gitea.service - Gitea (Git with a cup of tea) Loaded: loaded (/etc/systemd/system/gitea.service; enabled; vendor preset: disabled) Active: active (running) since Mon 2022-05-30 18:31:56 CEST; 2h 3min ago Main PID: 4532 (gitea) Tasks: 7 (limit: 5925) Memory: 241.1M CPU: 19.328s CGroup: /system.slice/gitea.service └─4532 /usr/local/bin/gitea web --config /etc/gitea/app.ini
Configuring Gitea
Now that Gitea is installed, it’s time to configure it to suit your needs. Here are the steps to configure Gitea:
- Allow the Gitea port through the firewall:
firewall-cmd --permanent --zone=public --add-port=3000/tcp firewall-cmd --reload
- Access Gitea through your browser by entering the following URL:
http://yourserver-ip-address:3000
- Follow the on-screen instructions to complete the Gitea setup. Click on “Register” to start the database initialization.
- Fill in the database settings:
- Database Type: Select SQLite3.
- Path: Use an absolute path, such as
/var/lib/gitea/data/gitea.db
.
- Configure the application general settings:
- 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: Keep the default value
22
unless you are using a different SSH port. - Gitea HTTP Listen Port: Keep the default value
3000
. - Gitea Base URL: Use
http
followed by your domain or server IP address. - Log Path: Keep the default value
/var/lib/gitea/log
.
- Click on “Install” to complete the Gitea installation.
- Once the installation is completed, create the first user by opening the following URL in your web browser:
http://yourip:3000/user/sign_up
Fill in the required details and submit the form.
Congratulations! You have successfully installed and configured Gitea on AlmaLinux 9. You can now start using Gitea to manage your software development projects efficiently.
At Shape.host, we offer reliable and scalable Cloud VPS solutions to empower businesses with efficient hosting services. Contact us today to learn more about how Shape.host can help you streamline your software development workflow and ensure the secure hosting of your Gitea instance.