Operations 4 min read

How to Self‑Host Gitea for Secure, Easy Project Management

This guide walks individual developers through installing Gitea—using Docker‑compose or binary packages—configuring a systemd service for automatic startup, accessing the web UI to create a repository, and linking it with IDEs to push code, providing a lightweight, self‑hosted Git platform for secure project management.

Black & White Path
Black & White Path
Black & White Path
How to Self‑Host Gitea for Secure, Easy Project Management

Gitea is a lightweight DevOps platform derived from Gogs, designed to be easy to install, fast to run, and user‑friendly for self‑hosted Git services.

The article outlines several installation options, including binary packages, source builds, and Docker. Docker deployment is recommended for simplicity.

Example docker-compose.yml:

version: "2"
services:
  server:
    image: docker.gitea.com/gitea:1.26.1-rootless
    restart: always
    volumes:
      - ./data:/var/lib/gitea
      - ./config:/etc/gitea
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "3000:3000"
      - "2222:2222"

Alternatively, the binary package can be downloaded from https://dl.gitea.com/gitea/. After extracting, the following commands set up a dedicated git user and start the service:

# Create git user with home directory and bash shell
/usr/sbin/useradd -m -s /bin/bash git
# Set password for git user
/usr/bin/passwd git
chmod +x gitea-1.26.1-linux-arm64
./gitea-1.26.1-linux-arm64 web

Once the service is running, the web UI can be accessed to complete the initial configuration (screenshots omitted for brevity).

To ensure the service starts on boot, a systemd unit file is created:

# Create systemd service
cat > /etc/systemd/system/gitea.service << 'EOF'
[Unit]
Description=Gitea
After=network-online.target
[Service]
ExecStart=/home/git/gitea-1.26.1-linux-arm64 web
WorkingDirectory=/home/git
User=git
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
# Reload daemon and enable service
systemctl daemon-reload
systemctl enable --now gitea

The project directory is home/git/gitea-1.26.1-linux-arm64. Service status can be checked and controlled with standard systemctl commands:

systemctl status gitea   # view status
systemctl stop gitea      # stop service
systemctl start gitea     # start service

After the web UI is configured, a new repository can be created (illustrated with screenshots). Developers can then configure Git credentials in IDEs such as IntelliJ IDEA and push code to the newly created repository.

In summary, building a self‑hosted Git platform with Gitea gives developers tighter control over code iteration and enhances security, making it a practical solution for personal and small‑team projects.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DockerDevOpsGitSystemdSelf-hostedGitea
Black & White Path
Written by

Black & White Path

We are the beacon of the cyber world, a stepping stone on the road to security.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.