Gitea is a lightweight, self-hosted Git service. You can use it to manage repositories in your browser, work with issues and pull requests, create wikis and releases, and automate tasks such as tests or builds with Gitea Actions. Its interface is similar to GitHub, but your data stays on your own server. This guide shows you two ways to set it up: the easy way, as a One-Click App that makes Gitea available over HTTPS in just a few clicks, and a manual installation with Docker Compose. After that, you’ll create your first repository and clone it over HTTPS or SSH.
Running your own Git server is worthwhile if:
- You don’t want your code stored with a third-party provider, for example for private projects, client projects, or configuration files.
- You want to bring together a small team or multiple projects, with users, organizations, and permissions for each repository.
- You have limited resources: According to the Gitea documentation, 2 CPU cores and 1 GB of RAM are usually enough for small teams and projects.
- You want to mirror or migrate repositories from GitHub or GitLab to keep your own copy.
Gitea is less suitable if you’re looking for a complete DevOps platform with security scans and large CI/CD pipelines. GitLab is better suited to that, but it requires considerably more memory. See Install GitLab.
The app catalog offers several Git services. Here’s a quick comparison:
| Gitea | Forgejo | GitLab | |
|---|---|---|---|
| Origin | Independent project, originally a fork of Gogs | Forked from Gitea in October 2022 and developed under the umbrella of the nonprofit Codeberg e.V. | Independent platform |
| Interface | Very similar to GitHub | Very similar to Gitea | Its own extensive interface |
| Resources | Low | Low | High (GitLab lists 8 GB RAM as a minimum) |
| CI/CD | Gitea Actions with its own runner | Forgejo Actions with its own runner | GitLab CI/CD with GitLab Runner |
Forgejo emphasizes free software and community governance, while Gitea is backed by a company that also offers Cloud and Enterprise versions. Both work well as your own small Git server. This guide covers Gitea.
The quickest way to get Gitea running is through your VPS’s One-Click Apps. The app is available directly over HTTPS with a domain; you don’t need a reverse proxy or certificate. The app also opens port 22222 for git clone over SSH.
The app catalog offers Gitea in four options. The only difference is the database:
| Option | Database | Containers |
|---|---|---|
| Gitea | SQLite, a single file in the data volume | 1 |
| Gitea with PostgreSQL | PostgreSQL 18 | 2 |
| Gitea with MariaDB | MariaDB 11 | 2 |
| Gitea with MySQL | MySQL 8.0 | 2 |
The Gitea option with SQLite is enough for you or a small team. If you expect to have many users and repositories, or prefer a dedicated database, choose Gitea with PostgreSQL. You can’t easily switch options later, so decide before installation. There’s also Gitea Runner, the execution environment for Gitea Actions (see below).
- A Linux VPS (Debian or Ubuntu) with One-Click Apps set up. For instructions, see Set up One-Click Apps.
- Enough resources: The One-Click App needs only 256 MB of free memory, but 512 MB is recommended. You’ll need more if you use a separate database, have many repositories, or run Actions.
- Open your VPS in the ZapX dashboard and go to the One-Click Apps tab.
- Search the app catalog for Gitea, select the option you want, and click Install app.
- Use a custom subdomain or zap.cloud is already selected, with a randomly generated name. Leave it enabled or enter your own name: You’ll use the domain to access Gitea over HTTPS, and Gitea will use it as the address for clone links.
- The Gitea option has no additional fields. For the database options, the app generates a database username and password for you, so you don’t need to enter anything.
- Click Queue installation. After one or two minutes, Gitea will show as online on the app card. Under Connection, the card also shows the IP address with SSH port
22222.
Gitea doesn’t come with default login credentials. The first time you open it, the Initial Configuration page appears. Whoever completes it first creates the administrator account.
Open Gitea immediately after installation Until you complete the initial setup, anyone who knows the address can open the Initial Configuration page and make themselves an administrator. Open the app’s Access link as soon as the app is online.
- Open the app’s Access link.
- Leave the database fields at the top unchanged. For the Gitea option, SQLite3 is shown there; for the database options, the app provides the connection details.
- Enter
22222under SSH Server Port. If you leave the default value of22, the SSH clone links will show the wrong port later. - Gitea Website URL is pre-filled with your domain. Leave it as is.
- Select Only administrators can create user accounts (no self-registration) if you don’t want users to register themselves. If you leave it unchecked, any visitor can create an account.
- Expand Administrator Account Settings and enter a username, email address, and strong password.
- Click Install Gitea. After a few seconds, you’ll be signed in as the administrator.
If you leave Administrator Account Settings blank, the first account registered afterward becomes the administrator. The settings are stored in /data/gitea/conf/app.ini in the data volume.
During testing, Gitea initially showed the SSH clone address as ssh://git@localhost:22222/... because the One-Click App only sets the domain for HTTPS. You can fix this with an environment variable:
- Open the app settings using the gear icon and go to App environment.
- Under Custom environment variables, click the plus icon to add a variable: key
GITEA__server__SSH_DOMAIN, value your domain withouthttps://, for example,git.example.com. - Click Save. The app will briefly restart and apply the value.
After that, the clone addresses will look like ssh://git@git.example.com:22222/USERNAME/REPO.git. You can set any option from app.ini using the same pattern, GITEA__<section>__<key>. Gitea applies the value each time it starts.
SSH port 22222
Port 22222 is fixed for the app. If you use your own firewall on the server, allow port 22222/tcp. Only one Gitea app can use this port per VPS.
Update Gitea in the app settings (gear icon), under App update. Click Check for updates and install a new version with Apply update. If the page says the app is up to date, there isn’t a newer version in the app catalog yet.
Repositories, users, and settings are stored in Docker volumes and are retained during updates. However, a volume isn’t a backup. Gitea includes the gitea dump command, which packages everything into a ZIP file. Run this over SSH on your VPS:
C=$(docker ps --format '{{.Names}}' | grep '^gitea-')
docker exec -u git -w /tmp $C bash -c '/usr/local/bin/gitea dump -c /data/gitea/conf/app.ini'
docker exec $C sh -c 'ls /tmp/gitea-dump-*.zip'
Copy the displayed file to the server with docker cp $C:/tmp/FILE_NAME.zip ., then copy it from there to your computer over SFTP. According to the Gitea documentation, the backup is only guaranteed to be consistent if nobody pushes or migrates repositories while it’s running.
The rest of this guide covers a manual installation of Gitea with Docker Compose, following the official Gitea documentation. For example, you might use this approach if you don’t use One-Click Apps on your server or want to manage everything yourself.
- A Linux VPS running Debian or Ubuntu, with SSH access. See First SSH connection.
- Docker and Docker Compose. See Install Docker. Check the installation with
docker --versionanddocker compose version. - For HTTPS: a domain or subdomain with an A record pointing to your VPS’s IP address (for example,
git.example.com).
| Resource | Minimum | Recommended |
|---|---|---|
| CPU | 1 core | 2 cores |
| RAM | 256 MB | 1 GB |
| Storage | System, images, and your repositories | Additional space for growth and backups |
The minimum matches the One-Click App’s requirements; the recommended value is based on the Gitea documentation for small teams. Allow for more memory if you’re running PostgreSQL and Gitea Actions on the same server.
Gitea uses port 3000 for the web interface and port 22 inside the container for SSH. You’ll access the web interface through the reverse proxy, so you don’t need to open port 3000. For SSH, we’ll use port 2222 on the server because port 22 is already used for the server’s SSH access. With ufw, allow only the ports you need:
ufw allow OpenSSH
ufw allow 80/tcp
ufw allow 443/tcp
ufw allow 2222/tcp
ufw enable
Docker bypasses ufw
Ports published by Docker using ports: are reachable from outside even if ufw blocks them. That’s why you should bind the web interface to 127.0.0.1, as in the Compose file below. For more about the firewall, see Managing the firewall on Linux.
Create a directory for Gitea and navigate to it:
mkdir -p /opt/gitea
cd /opt/gitea
Create the Compose file with nano docker-compose.yml. It follows the PostgreSQL example in the Gitea documentation:
networks:
gitea:
external: false
services:
server:
image: docker.gitea.com/gitea:28.4.0
container_name: gitea
environment:
- USER_UID=1000
- USER_GID=1000
- GITEA__database__DB_TYPE=postgres
- GITEA__database__HOST=db:5432
- GITEA__database__NAME=gitea
- GITEA__database__USER=gitea
- GITEA__database__PASSWD=DB_PASSWORD
- GITEA__server__ROOT_URL=https://git.example.com/
- GITEA__server__SSH_DOMAIN=git.example.com
- GITEA__server__SSH_PORT=2222
restart: always
networks:
- gitea
volumes:
- ./gitea:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "127.0.0.1:3000:3000"
- "2222:22"
depends_on:
- db
db:
image: docker.io/library/postgres:18
restart: always
environment:
- POSTGRES_USER=gitea
- POSTGRES_PASSWORD=DB_PASSWORD
- POSTGRES_DB=gitea
networks:
- gitea
volumes:
- ./postgres:/var/lib/postgresql
Here’s what the entries mean:
image: Gitea 28.4.0 in a fixed version, as in the One-Click App. This lets you decide when to update.USER_UIDandUSER_GID: Gitea creates its files in thegiteadirectory with this user and group ID.GITEA__database__...: The database connection. ReplaceDB_PASSWORDin both places with the same strong, randomly generated password.GITEA__server__...: The public address, hostname, and port for SSH clone links. Replacegit.example.comwith your domain.127.0.0.1:3000:3000: The web interface is only accessible from the server itself. External access goes through the reverse proxy.2222:22: Server port2222forwards to the SSH service in the container.postgres:18: The documentation deliberately pins the major version because PostgreSQL doesn’t automatically migrate data when you change major versions.
If you don’t need a separate database, remove the db service, depends_on, and the GITEA__database__ lines. Gitea will then use SQLite.
Start the containers:
docker compose up -d
Check whether they’re running with docker compose ps and view the logs with docker compose logs -f.
Since the web interface only listens on 127.0.0.1, it’s best to set up the reverse proxy in the next section first, then access Gitea directly at https://git.example.com. Alternatively, open the page from your computer using an SSH tunnel:
ssh -L 3000:localhost:3000 root@SERVER_IP
Replace SERVER_IP with your VPS’s IP address, then open http://localhost:3000 in your browser. The Initial Configuration page will appear. The database is already configured. Check that SSH Server Port is set to 2222 and Gitea Website URL contains your domain. If needed, select the option to disable self-registration, create your admin account under Administrator Account Settings, and click Install Gitea.
To access Gitea externally, set up a reverse proxy with a valid certificate in front of it. For the basics, see Set up a reverse proxy with nginx and Create an SSL certificate (Let's Encrypt). Here’s an nginx server block based on the example in the Gitea documentation:
server {
listen 80;
server_name git.example.com;
client_max_body_size 512M;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Connection $http_connection;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
client_max_body_size allows larger uploads; otherwise, nginx stops them with the “413 Request Entity Too Large” error. Gitea needs proxy_http_version and the Upgrade and Connection lines for its WebSocket connection, which is used to update things like the notification counter in real time. Then get a certificate with certbot --nginx -d git.example.com. Certbot adds HTTPS and HTTP redirection to the block. For more security tips, see Linux security tips.
All data is stored in the gitea and postgres directories next to the Compose file. Stop the containers first so the repositories and database stay in sync:
cd /opt/gitea
docker compose stop
tar -czf /root/gitea-backup-$(date +%F).tar.gz gitea postgres docker-compose.yml
docker compose start
Then copy the archive to another storage location.
Before each update, check the release notes for changes that affect you, and back up your data. Changing the second version number migrates the database to a new format; after that, you can only roll back using a backup. Update the version number in docker-compose.yml and restart Gitea:
cd /opt/gitea
docker compose pull
docker compose up -d
Remove old images with docker image prune. Keep the PostgreSQL image on the same major version.
After setup, create your first repository using the plus icon in the top-right corner > New Repository. Select Initialize Repository to have Gitea create a README file so you can clone it right away. You can migrate existing repositories, for example from GitHub or GitLab, using New Migration in the same menu.
Find the clone address in the repository by clicking Code and selecting the HTTPS tab:
git clone https://git.example.com/USERNAME/REPO.git
Git will ask for your Gitea username and password. If you’ve enabled two-factor authentication, use an access token instead of your password. You can create one under Settings > Applications.
To use SSH, add your public key once under Settings > SSH / GPG Keys > Add Key. For instructions on generating a key pair, see Create an SSH key. Find the address under the SSH tab in Code:
git clone ssh://git@git.example.com:22222/USERNAME/REPO.git
The port is 22222 for the One-Click App and 2222 for a manual installation. During testing, cloning and pushing worked both ways.
Gitea Actions has been enabled since version 1.21. During testing, new repositories displayed the Actions tab right away. If it’s missing for you, enable Actions in the repository settings under Settings by selecting Enable Repository Actions. Write workflows in the .gitea/workflows directory, just as you would with GitHub Actions. A Gitea Runner executes them:
- As a One-Click App: Install the Gitea Runner app. The required fields are
GITEA_INSTANCE_URL(the address of your Gitea instance, for example,https://git.example.com) andGITEA_RUNNER_REGISTRATION_TOKEN. You can find the token for an instance-wide runner in the administration area under Site Administration > Actions > Runners (address/-/admin/actions/runners). By default, jobs with theubuntu-latestlabel run in a container with Node.js 22. - Manual installation: Install the runner as a program or container by following the runner documentation, then register it with the same token.
The Gitea documentation recommends running runners on a different machine from Gitea so builds don’t slow down the Git server. The runner controls Docker on the server, so only use it for repositories you trust. Workflows remain queued if no runner is connected.
- Storage space: Repositories, releases, LFS files, and packages take up space on your VPS. If you run out, increase its size in the Manage plan tab for your VPS.
- Email: Gitea can’t send notifications or password links without a mail server. Enter the details during initial setup under Email Settings, or later using
GITEA__mailer__variables. - Database option: You can’t switch the One-Click App from SQLite to PostgreSQL with a single click.
You’ve set up Gitea on your VPS, created an admin account, and learned how to clone and back up repositories over HTTPS and SSH. You now have your own lightweight Git server for your projects, one that runs well even on small servers.
Prefer not to manage Docker yourself? Take the easy route with the One-Click App, as described above in “The easy way: Gitea as a One-Click App.”