How to Install Gitea on OpenSUSE

This tutorial will guide you through the process of installing Gitea, a self-hosted Git service, on OpenSUSE Latest. Gitea is an open-source, lightweight and powerful Git server written in Go language. It offers an easy-to-use web interface that enables users to host their repositories, manage access, and collaborate with others.

Prerequisites

Before proceeding, make sure you have the following:

Step 1: Install Dependencies

Gitea requires several dependencies to be installed in order to function correctly. To install these, run the following command:

sudo zypper install git go nodejs npm mariadb mariadb-client

This will install the necessary packages:

Step 2: Create a System User for Gitea

Next, create a new user to run the Gitea service:

sudo useradd --system --shell /bin/bash --comment 'Git Version Control' --create-home --home-dir /home/git git

This will create a new system user named git with a home directory at /home/git.

Step 3: Build Gitea from Source

Now, we need to download and build Gitea from source. For this, we will use the go command-line tool:

sudo mkdir -p /opt/gitea
sudo chown git:git /opt/gitea

export GOPATH=/opt/gitea/
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin

go get -u code.gitea.io/gitea
cd $GOPATH/src/code.gitea.io/gitea
TAGS="bindata" make generate build

This will install the latest version of Gitea, and build it with support for embedded assets.

Step 4: Configure Gitea

Before starting Gitea, we need to create a configuration file:

sudo mkdir -p /etc/gitea
sudo touch /etc/gitea/app.ini
sudo chown git:git /etc/gitea/app.ini
sudo chmod 777 /etc/gitea/app.ini

Now, edit the app.ini file using your favorite text editor:

[server]
DOMAIN           = localhost
HTTP_PORT        = 3000
ROOT_URL         = http://localhost:3000/
LFS_START_SERVER = true
LFS_CONTENT_PATH = /opt/gitea/data/gitea/lfs

[database]
DB_TYPE  = mysql
HOST     = 127.0.0.1:3306
NAME     = gitea
USER     = root
PASSWD   = your_password
SSL_MODE = disable

[repository]
ROOT = /opt/gitea/data/git/repos

[security]
INSTALL_LOCK   = true
SECRET_KEY     = your_secret_key
INTERNAL_TOKEN = your_internal_token

[service]
DISABLE_REGISTRATION          = false
REQUIRE_SIGNIN_VIEW           = false
DEFAULT_KEEP_EMAIL_PRIVATE    = false
DEFAULT_ALLOW_CREATE_ORGANIZA = true
NO_REPLY_ADDRESS              =
ENABLE_NOTIFY_PUSH            = true
ENABLE_CAPTCHA                = true

Make sure to update the app.ini file to match your configuration. Pay attention to the DB_TYPE, HOST, NAME, USER, and PASSWD parameters under the [database] section, which should match your MariaDB database credentials.

Step 5: Start Gitea

With Gitea installed and configured, start the service with the following command:

sudo ln -sf $GOPATH/src/code.gitea.io/gitea/gitea /usr/local/bin/gitea
sudo chown git:git /usr/local/bin/gitea
sudo chmod +x /usr/local/bin/gitea

sudo mkdir -p /opt/gitea/data/gitea/lfs
sudo chown git:git /opt/gitea/data/gitea/lfs

sudo -u git -H /usr/local/bin/gitea web -c /etc/gitea/app.ini

Once started, Gitea should be accessible at http://localhost:3000.

Conclusion

You have now successfully installed and configured Gitea, a self-hosted Git service, on OpenSUSE Latest. You can now start using Gitea to create repositories, manage access, and collaborate with others.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!