How to Install Gitea on CentOS 8

How to Install Gitea on CentOS 8

Gitea is an open-source git self-hosted server written in Go. It comes with a file editor repository, project problem tracking, user management, notifications, built-in wikis, and more.

Gitea is a lightweight application and can be installed on less robust systems. If you are looking for a Gitlab alternative with a much smaller memory footprint and do not need all the bells and whistles that Gitlab has to offer, you should try Gitea.

This article shows you how to install and configure Gitea on CentOS 8.


Gitea supports SQLite, PostgreSQL, and MySQL / MariaDB as database backend.

We will use SQLite. This is a lightweight database that stores data in one file. If SQLite is not installed on your CentOS machine, you can install it by running the following command as a sudo user:

sudo dnf install sqlite

We assume that SELinux is disabled or set to permissive mode.

Install Gitea

Gitea can be installed from source, binary, and as a package. It can also be used as a Docker image. We will install Gitea using thr binary.

Install Git

The first step is to install Git on your CentOS:

sudo dnf install git

Verify the installation by displaying the Git version:

git --version
git version 2.18.4

For Git users

Create a new user system to run the Gitea application:

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

This will create a new user and group called git, and set the home directory to / home / git.

Download Gitea binary

The latest Gitea binaries can be downloaded from the Gitea Download page. Make sure you download the right binary for your architecture.

At the time of writing, the latest version is 1.12.3. If there is a new version available, change the VERSION variable in the command below.

Use wget to download Gitea binaries in the / tmp directory:

sudo wget -O /tmp/gitea${VERSION}/gitea-${VERSION}-linux-amd64

You can run binary from any location. We will follow the convention and move the binary to the / usr / local / bin directory:

sudo mv /tmp/gitea /usr/local/bin

Make binary workable:

sudo chmod +x /usr/local/bin/gitea

The following command will create the necessary directories and set the required permissions and ownership:

sudo mkdir -p /var/lib/gitea/{custom,data,indexers,public,log}
sudo chown git: /var/lib/gitea/{data,indexers,log}
sudo chmod 750 /var/lib/gitea/{data,indexers,log}
sudo mkdir /etc/gitea
sudo chown root:git /etc/gitea
sudo chmod 770 /etc/gitea

The directory structure above is recommended by the official Gitea documentation.

The / etc / gitea directory permission is set to 770 so that the installation wizard can create a configuration file. After the installation is complete, we will set stricter permissions.

Create a Systemd Unit File

Gitea provides Systemd unit files that are configured to match our settings.

Download the file to the / etc / systemd / system / directory by typing:

sudo wget -P /etc/systemd/system/

When finished, activate and start the Gitea service:

sudo systemctl daemon-reload
sudo systemctl enable --now gitea

Verify that the service was started successfully:

sudo systemctl status gitea
gitea.service - Gitea (Git with a cup of tea)
   Loaded: loaded (/etc/systemd/system/gitea.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2020-01-04 21:27:23 UTC; 3s ago
 Main PID: 14804 (gitea)
    Tasks: 9 (limit: 1152)
   CGroup: /system.slice/gitea.service
           └─14804 /usr/local/bin/gitea web --config /etc/gitea/app.ini

Configure Gitea

Now that Gitea is up and running, it’s time to complete the installation through the web interface.

By default, Gitea listens for connections on port 3000 on all network interfaces. You must configure your firewall to enable access to the Gitea web interface:

sudo firewall-cmd --permanent --zone=public --add-port=3000/tcp
sudo firewall-cmd --reload

Open your browser, enter http: // YOUR_DOMAIN_IR_IP: 3000 / install, and the initial configuration page will appear:


Fill in the required fields as follows:

Database Settings:

  • Database Type: SQLite3
  • Path: Use the absolute path, /var/lib/gitea/data/gitea.db

General Apps Settings:

  • Site Title – Enter the name of your organization.
  • Path Repository Root – Leave the default / home / git / gitea repository.
  • Git LFS Root Path – Leave the default / var / lib / gitea / data / lfs.
  • Run As Username – git
  • SSH Domain Server – Enter your domain or server’s IP address.
  • SSH Port – 22, change if SSH is listening in another Port
  • Gitea HTTP Listen Port – 3000
  • Gitea Base URL – Use your server’s http and domain or IP address.
  • Log Path – Leave the default / var / lib / gitea / log

When finished, press the “Install Gitea” button. Instant Installation. When finished, you will be directed to the login page.

Click the “Register now” link. The first registered user is automatically added to the Admin group.

To make the installation safer, change the permissions of the Gitea configuration file to read-only using:

sudo chmod 750 /etc/gitea
sudo chmod 640 /etc/gitea/app.ini

There she is. Gitea is installed on your CentOS machine.

Configure Nginx as an SSL Termination Proxy

This step is optional, but highly recommended. To use Nginx as a reverse proxy, you must have a domain or subdomain that points to your public IP server. In this tutorial, we will use

First, install Nginx and produce Allow free SSL certificate encryption using the guidelines below:

  • How to Install Nginx on CentOS 8
  • Secure Nginx with Let’s Encrypt on CentOS 8

When finished, open your text editor and edit the domain server block file:

sudo nano /etc/nginx/conf.d/
server {
    listen 80;

    include snippets/letsencrypt.conf;
    return 301$request_uri;

server {
    listen 443 ssl http2;

    proxy_read_timeout 720s;
    proxy_connect_timeout 720s;
    proxy_send_timeout 720s;

    client_max_body_size 50m;

    # Proxy headers
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Real-IP $remote_addr;

    # SSL parameters
    ssl_certificate /etc/letsencrypt/live/;
    ssl_certificate_key /etc/letsencrypt/live/;
    ssl_trusted_certificate /etc/letsencrypt/live/;
    include snippets/letsencrypt.conf;
    include snippets/ssl.conf;

    # log files
    access_log /var/log/nginx/;
    error_log /var/log/nginx/;

    # Handle / requests
    location / {
       proxy_redirect off;

Don’t forget to replace with your Gitea domain and set the correct path to the SSL certificate file. HTTP traffic is diverted to HTTPS.

When finished, restart the Nginx service so that the changes take effect:

sudo systemctl restart nginx

Next, change the Gitea domain and url root. To do this, open the configuration file and edit the following lines:

sudo nano /etc/gitea/app.ini
DOMAIN           =
ROOT_URL         =

Restart the Gitea service by typing:

sudo systemctl restart gitea

At this point, the Gitea proxy is configured, and you can access it at:

Configure Email Notifications

To have the notification email sent, you can install Postfix or use a transactional email service such as SendGrid, MailChimp, MailGun, or SES.

To enable email notifications, open the configuration file and edit the following lines:

sudo nano /etc/gitea/app.ini
ENABLED = true

Make sure you are using the correct SMTP server information.

Every time you edit the app.ini file, you must restart the Gitea service for the changes to take effect:

sudo systemctl restart gitea

To verify settings and send a trial email, log in to Gitea and go to: Site Administration> Configuration> SMTP Mailer Configuration.

Gitea also lets you connect to Slack by creating a webhook and sending notifications to your Slack channel.

Improvement of Gitea

Upgrading to the latest version of Gitea is an easy task. You only need to download and replace the binary.

  1. Stop Gitea services:
sudo systemctl stop gitea

2. Download the latest Gitea binaries and move them to the / usr / local / bin directory:

wget -O /tmp/gitea${VERSION}/gitea-${VERSION}-linux-amd64
sudo mv /tmp/gitea /usr/local/bin

3. Make binary workable:

sudo chmod +x /usr/local/bin/gitea

4. Restart Gitea service:

sudo systemctl restart gitea

There she is.


We have shown you how to install Gitea on CentOS 8. Now you must visit the Gitea documentation page and learn how to configure your installation and create your first project.

If you have questions, please leave a comment below.

Related posts

How to use BleachBit on Linux


How to Make a Tar Gz File


How to make Ubuntu look like Windows XP


How to Install CouchDB on Ubuntu 20.04


How to Install Notepadqq on Ubuntu 20.04, a decent Notepad ++ alternative


How to Install Docker on Ubuntu 20.04


How to Install Node.js and npm on Ubuntu 20.04


How to Add Elements to a List in Python (add, add and enter)


How to Install Webmin on Ubuntu 20.04