Gitea Setup Guide | Installation Methods for Linux

Design of engineers setting up Gitea on Linux in an IOFLOOD datacenter enhancing code collaboration

We utilize self-hosted Git repository solutions commonly while developing software for Linux servers at IOFLOOD. From our experience, Gitea’s user-friendly Git workflows and collaboration tools makes it an ideal platform for managing code repositories and projects. Todays article has been filled with tips and tricks too empower our customers and fellow developers with the knowledge and steps required to enhance their collaboritive programming experience on dedicated Remote servers.

In this guide, we will navigate you through the process of installing Gitea on your Linux system. We will show you methods for installing with APT distros like Ubuntu and Debian as well as YUM-based distributions like CentOS and AlmaLinux. We’ll also delve into more advanced topics like compiling Gitea from the source, how to install a specific version, and finally, how to use the Gitea command and verify that the correct version is installed.

Let’s dive in and begin installing Gitea on your Linux system!

TL;DR: How Do I Install Gitea on Linux?

To install Gitea on Debian-based systems like Ubuntu, use sudo apt-get install gitea. For RPM-based systems like CentOS, use sudo yum install gitea. You can then access Gitea via your web browser at http://localhost:3000 after starting the Gitea service. You can also download the Gitea binary from the official website using the wget command.

Here’s a quick example:

wget -O gitea https://dl.gitea.io/gitea/1.14.1/gitea-1.14.1-linux-amd64
chmod +x gitea
./gitea web

This will download the Gitea binary, make it executable, and start the Gitea web service. You should now be able to access Gitea at http://localhost:3000 in your web browser.

While this is a basic way to install Gitea on Linux, there’s much more to learn about installing and using Gitea. Continue reading for more detailed information and advanced installation options.

Basic Gitea Installation on Linux

Gitea is a self-hosted Git service, much like GitHub or GitLab, but significantly lighter and easy to install. It’s a fantastic tool for developers and teams who want to manage their Git repositories on their own server, offering a user-friendly interface and a host of features.

Now, let’s discuss how to install Gitea on Linux. We will primarily focus on two package management systems, APT and YUM, which are widely used in various Linux distributions.

Installing Gitea with APT (Debian, Ubuntu)

If you’re using a Debian-based distribution like Ubuntu, you can install Gitea using the APT package manager. Here’s how:

sudo apt-get update
sudo apt-get install git
wget -O gitea https://dl.gitea.io/gitea/1.14.1/gitea-1.14.1-linux-amd64
chmod +x gitea

In this code block, we first update the package lists for upgrades and new package installations (sudo apt-get update). Next, we install Git (sudo apt-get install git). We then download the latest Gitea binary using the wget command and make it executable with chmod +x gitea.

Installing Gitea with YUM (CentOS, RHEL)

If you’re using a Red Hat-based distribution like CentOS, you can use the YUM package manager to install Gitea. Here’s the process:

sudo yum update
sudo yum install git
wget -O gitea https://dl.gitea.io/gitea/1.14.1/gitea-1.14.1-linux-amd64
chmod +x gitea

This code block is very similar to the APT one. We start by updating the system (sudo yum update), then install Git (sudo yum install git). Finally, we download the Gitea binary and make it executable (chmod +x gitea).

In both methods, you have now installed Gitea on your Linux system. You can start the Gitea service by running ./gitea web in the directory where you downloaded the binary.

Installing Gitea from Source

For those who prefer building from source or need a specific version of Gitea, you can compile Gitea from the source code. This method offers a greater level of control over the installation process and can be beneficial for developers who wish to modify or extend the functionality of Gitea.

Here’s how you can install Gitea from source:

sudo apt-get install git golang
mkdir -p $GOPATH/src/code.gitea.io
cd $GOPATH/src/code.gitea.io
git clone https://github.com/go-gitea/gitea.git
cd gitea
TAGS="bindata" make build

This will install the necessary dependencies (git and golang), clone the Gitea repository, and build the Gitea binary.

Installing Different Versions of Gitea

Installing Specific Version from Source

If you need a specific version of Gitea, you can check out the desired version’s tag before building. Here’s how:

cd $GOPATH/src/code.gitea.io/gitea
git checkout v1.14.1
TAGS="bindata" make build

This will build Gitea version 1.14.1 from source.

Installing Specific Version with Package Managers

With APT

On Debian-based distributions, you can install a specific version of a package using the = operator followed by the version number. However, Gitea’s binary releases are not available in the official Debian or Ubuntu repositories, so you can’t install a specific version with APT. You’ll have to download the specific version from the Gitea website or build it from source.

With YUM

Like APT, YUM doesn’t support installing a specific version of Gitea because it’s not available in the official repositories of Red Hat-based distributions. You’ll need to download the specific version from the Gitea website or build it from source.

Version Comparison

Each version of Gitea includes new features, improvements, and bug fixes. You can find detailed release notes on the Gitea blog.

Here’s a brief comparison of the last three versions:

VersionKey FeaturesRelease Date
1.14.1Improved issue search, added support for PostgreSQL 13April 2021
1.14.0Added support for custom avatars, improved OAuth2 supportMarch 2021
1.13.0Added support for PostgreSQL 12, improved Docker supportDecember 2020

Using and Verifying Gitea

Basic Usage of Gitea

Once you’ve installed Gitea, you can start it with the ./gitea web command. This will start the Gitea web service, and you can access Gitea at http://localhost:3000 in your web browser.

Verifying the Installation

You can verify that Gitea is installed correctly and check its version with the ./gitea --version command:

./gitea --version

This command should output the version of Gitea that you installed, like this:

Gitea version 1.14.1 built with GNU Make 4.1, go1.15.6 : bindata, sqlite, sqlite_unlock_notify

This confirms that Gitea version 1.14.1 is installed correctly.

Alternative Git Services

While Gitea is a powerful and lightweight self-hosted Git service, it’s not the only option out there. Depending on your needs, you might find GitLab or GitHub to be more suitable. Let’s explore these alternatives and how to set them up on your Linux system.

GitLab: An All-in-One DevOps Platform

GitLab is a comprehensive DevOps platform that integrates a Git repository manager with CI/CD capabilities, issue tracking, and more. GitLab’s extensive feature set makes it an excellent choice for teams looking for an all-in-one solution.

To install GitLab on Ubuntu, you can use the Omnibus package, which includes all dependencies and can be configured with a single command:

sudo apt-get update
sudo apt-get install -y curl openssh-server ca-certificates tzdata postfix
sudo curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
sudo apt-get install gitlab-ce

The expected output will be a series of status messages indicating that GitLab and its dependencies are being installed. Once the installation is complete, you can access GitLab by navigating to http://localhost in your web browser.

GitHub: The World’s Largest Open Source Community

GitHub is the world’s largest open source community and a platform for developers to collaborate on projects. While GitHub is primarily a cloud-based service, you can use GitHub’s command-line interface, GitHub CLI, to interact with GitHub from your Linux system.

To install GitHub CLI on Ubuntu, you can use the following commands:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0
sudo apt-add-repository https://cli.github.com/packages
sudo apt update
sudo apt install gh

The expected output will be a series of status messages indicating that GitHub CLI is being installed. Once the installation is complete, you can start using GitHub CLI by typing gh in your terminal.

Choosing the Right Git Service

While Gitea, GitLab, and GitHub all offer robust Git services, the best one for you depends on your specific needs. If you’re looking for a lightweight, self-hosted solution, Gitea is an excellent choice. If you need a comprehensive DevOps platform, consider GitLab. If you want to collaborate with the world’s largest open source community, GitHub is the way to go.

Troubleshooting Gitea Installations

Installing Gitea on Linux is generally a smooth process, but like any software installation, you might encounter some issues. Here, we’ll discuss common problems and their solutions, along with some tips for a successful installation.

Issue: Permission Denied

One common issue when installing Gitea is a ‘Permission Denied’ error. This typically happens when you try to execute the Gitea binary without the necessary permissions.

To solve this issue, you need to make the binary executable using the chmod command. Here’s how:

chmod +x gitea

This command changes the permissions of the gitea file and makes it executable. After running this command, you should be able to start the Gitea service without any ‘Permission Denied’ errors.

Issue: Gitea Service Not Starting

Sometimes, after installing Gitea and making the binary executable, the Gitea service might not start when you run ./gitea web. This could be due to various reasons, such as port conflicts or insufficient system resources.

To troubleshoot this issue, you can check the Gitea log file, which is typically located at /var/log/gitea/gitea.log:

cat /var/log/gitea/gitea.log

This command will display the contents of the log file, which should give you clues about why the Gitea service isn’t starting.

Considerations for a Smooth Installation

When installing Gitea on Linux, consider the following tips for a smooth installation:

  • Update Your System: Always start by updating your system packages. This ensures that you have the latest security patches and software updates, which can prevent installation issues.

  • Check System Requirements: Make sure your system meets the minimum requirements for running Gitea. This includes having a compatible operating system and enough disk space and memory.

  • Follow the Documentation: The official Gitea documentation is a valuable resource. It offers detailed installation guides for various operating systems and configurations.

  • Ask for Help: If you’re stuck, don’t hesitate to ask for help. The Gitea community is active and supportive, and you can usually find help on the Gitea Discourse forum or Gitea GitHub page.

By being aware of potential issues and how to solve them, you’ll be well-prepared for a successful Gitea installation.

Importance of Version Control Systems

Version Control Systems (VCS) are a critical tool in software development. They track and manage changes to the codebase, allowing developers to work simultaneously without overwriting each other’s changes. They also provide a historical record of the code, making it easy to roll back changes if needed.

One of the most popular VCS is Git. It’s a distributed version control system that allows multiple developers to work on a project simultaneously. Git provides a robust and efficient way to manage large codebases and is used by developers worldwide.

git init
git add .
git commit -m 'Initial commit'

In this code block, we initialize a new Git repository with git init, add all files in the current directory to the staging area with git add ., and make our first commit with git commit -m 'Initial commit'. This sets the foundation for tracking and managing changes to our project.

The Power of Self-Hosted Git Services

While Git provides the framework for version control, it’s often used in conjunction with a Git service like GitHub, GitLab, or Gitea. These services offer a user-friendly interface for managing Git repositories, along with additional features like issue tracking, pull requests, and continuous integration.

Self-hosted Git services offer several advantages. They provide full control over the server, enhanced security, and the flexibility to customize the service to fit your needs. For teams concerned about privacy and data security, a self-hosted Git service is an excellent choice.

Why Choose Gitea?

Gitea stands out among self-hosted Git services for its lightweight design and ease of installation. It’s written in Go, making it extremely efficient and capable of running on minimal hardware. This makes Gitea a great choice for small teams or individual developers.

In addition to its lightweight design, Gitea offers a host of features, including a user-friendly web interface, issue tracking, and built-in wiki. It also supports LDAP authentication, making it easy to integrate with your existing user management system.

./gitea admin create-user --username myuser --password mypassword --email [email protected]

In this code block, we use the Gitea command-line interface to create a new user. The ./gitea admin create-user command creates a new user with the specified username, password, and email. This demonstrates the ease of user management in Gitea.

In conclusion, whether you’re a solo developer or part of a team, Gitea offers a lightweight, efficient, and feature-rich platform for managing your Git repositories.

Role of Gitea in DevOps

Gitea is not only a self-hosted Git service but also a powerful tool in the realm of DevOps and Continuous Integration/Continuous Deployment (CI/CD) pipelines. Its lightweight design and efficient performance make it an attractive choice for organizations looking to streamline their development operations.

Gitea in DevOps

In a DevOps environment, Gitea can serve as the central hub for codebase management. It can integrate with various DevOps tools, enabling seamless collaboration between development and operations teams. For instance, Gitea can work with Jenkins, a popular open-source automation server, to automate parts of the development process, such as building, testing, and deploying applications.

Gitea in CI/CD Pipelines

Gitea’s support for webhooks is particularly useful in CI/CD pipelines. Webhooks allow Gitea to notify other services when specific events occur, such as when a developer pushes a commit. This feature can trigger automated testing or deployment tasks, enhancing the efficiency of the CI/CD pipeline.

# Example of setting up a webhook in Gitea

# Navigate to your repository in Gitea
# Click on 'Settings' -> 'Webhooks'
# Click on 'Add Webhook' -> 'Gitea'
# Fill in the 'Target URL' with your Jenkins server URL
# Click on 'Add Webhook'

In this code block, we demonstrate how to set up a webhook in Gitea to notify a Jenkins server when changes are pushed to the repository. The comments guide you through the process, which involves navigating to the repository settings in Gitea, adding a new webhook, and specifying the target URL of the Jenkins server.

Setting Up a Gitea Server

Setting up your own Gitea server can provide even greater control over your Git repositories. You can customize the server’s configuration to suit your needs, including adjusting the server’s port, enabling HTTPS, and more.

Further Resources for Gitea Proficiency

To deepen your understanding of Gitea and its capabilities, consider exploring the following resources:

  1. Gitea’s Official Documentation: A comprehensive guide to Gitea, including installation instructions, usage guides, and more.

  2. Gitea’s GitHub Page: The official GitHub repository for Gitea, where you can find the source code, contribute to the project, and report issues.

  3. Awesome Gitea: A curated list of resources related to Gitea, including plugins, themes, and tutorials.

By leveraging these resources, you can expand your knowledge of Gitea and make the most of this powerful self-hosted Git service.

Wrap Up: Gitea Linux Installation

In this comprehensive guide, we’ve explored how to install Gitea, a lightweight and efficient self-hosted Git service, on Linux.

We began with the basics, walking through a step-by-step guide on how to install Gitea on Linux using package managers like APT and YUM. We then delved into more advanced topics, such as installing Gitea from source, installing specific versions of Gitea, and verifying the installed version.

Along the way, we tackled common issues you might encounter when installing Gitea, such as ‘Permission Denied’ errors and the Gitea service not starting. We provided solutions and tips for a smooth installation, ensuring you can overcome any challenges that come your way.

We also took a look at alternative approaches to setting up a Git service on Linux, comparing Gitea with other popular Git services like GitLab and GitHub. Here’s a quick comparison of these services:

ServiceSelf-hostedFeaturesEase of Use
GiteaYesLightweight, efficient, easy to installHigh
GitLabYesComprehensive DevOps platformModerate
GitHubNoLargest open source community, cloud-based serviceHigh

Whether you’re just starting out with Gitea or you’re looking to level up your skills, we hope this guide has given you a deeper understanding of Gitea and its capabilities.

With its balance of lightweight design, efficiency, and ease of installation, Gitea is a powerful tool for managing your Git repositories on Linux. Happy coding!