This guide will help you to Install Gitea self-hosted Git service on CentOS 7 / CentOS 8 server, and use Nginx to proxy all requests to Gitea. Gitea is a painless self-hosted Git service forked from Gogs. It is similar to GitHub, Bitbucket, and Gitlab in functionalities.

Gitea has been build to be fast, easy to use, and most painless way of setting up a self-hosted Git service with minimal resource usage. Gitea is written in Go and runs across all platforms (Linux, macOS, and Windows) and architectures that support Go.

For Ubuntu use How to Install Gitea self-hosted Git service on Ubuntu

Step 1: Update system and install git

Update all system packages and install git by running

sudo yum -y update
sudo yum -y install git wget vim bash-completion
sudo reboot

Step 2: Add git system user and create directories

Add git user account that will be used by Gitea.

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

Create the required directory structure

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

Step 3: Install MariaDB database server

We will use MariaDB to store Gitea data, install MariaDB on your server by following our previous guide

Install MariaDB 10.x on Ubuntu 18.04 and CentOS 7

Install MariaDB CentOS 8

Create a database for Gitea:

# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 608168
Server version: 10.3.9-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> CREATE DATABASE gitea;
Query OK, 1 row affected (0.001 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON gitea.* TO 'gitea'@'localhost' IDENTIFIED BY "StrongPassword";
Query OK, 0 rows affected (0.001 sec)

Query OK, 0 rows affected (0.002 sec)
MariaDB [(none)]> exit

Step 4: Install and configure Gitea

Now download gitea binary from the Downloads page. Check the latest release before downloading it.

export VER=1.9.4

Move the downloaded binary file to the /use/local/bindirectory

chmod +x gitea-${VER}-linux-amd64
sudo mv gitea-${VER}-linux-amd64 /usr/local/bin/gitea

You can confirm version installed using

$ gitea --version
Gitea version 1.9.4 built with GNU Make 4.1, go1.12.9 : bindata, sqlite, sqlite_unlock_notify

Help page can be printed with --help option

~$ gitea --help
   Gitea - A painless self-hosted Git service

   gitea [global options] command [command options] [arguments...]

   1.9.4 built with GNU Make 4.1, go1.12.9 : bindata, sqlite, sqlite_unlock_notify

   By default, gitea will start serving using the webserver with no
arguments - which can alternatively be run by running the subcommand web.

     web       Start Gitea web server
     serv      This command should only be called by SSH shell
     hook      Delegate commands to corresponding Git hooks
     dump      Dump Gitea files and database
     cert      Generate self-signed certificate
     admin     Command line interface to perform common administrative operations
     generate  Command line interface for running generators
     migrate   Migrate the database
     keys      This command queries the Gitea database to get the authorized command for a given ssh key fingerprint
     convert   Convert the database
     help, h   Shows a list of commands or help for one command

   --port value, -p value         Temporary port number to prevent conflict (default: "3000")
   --pid value, -P value          Custom pid file path (default: "/var/run/")
   --custom-path value, -C value  Custom path file path (default: "/usr/local/bin/custom")
   --config value, -c value       Custom configuration file path (default: "/usr/local/bin/custom/conf/app.ini")
   --version, -v                  print the version
   --work-path value, -w value    Set the gitea working path (default: "/usr/local/bin")
   --help, -h                     show help

     CustomPath:  /usr/local/bin/custom 
     CustomConf:  /usr/local/bin/custom/conf/app.ini
     AppPath:     /usr/local/bin/gitea
     AppWorkPath: /usr/local/bin

Create a systemd service unit

sudo vim /etc/systemd/system/gitea.service

Configure the file to set UserGroup and WorkDir

Description=Gitea (Git with a cup of tea)

# Modify these two values and uncomment them if you have
# repos with lots of files and get an HTTP error 500 because
# of that
ExecStart=/usr/local/bin/gitea web -c /etc/gitea/app.ini
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea
# If you want to bind Gitea to a port below 1024 uncomment
# the two values below


Reload systemd and restart service

sudo systemctl daemon-reload
sudo systemctl restart gitea

Also enable the service to start on boot

sudo systemctl enable gitea

Step 5: Configure Nginx Reverse Proxy

If you would like to access Gitea UI using a domain name without a port, you need to configure Apache or NGINX reverse proxy

sudo yum install nginx

Create a VirtualHost reverse proxy configuration file

sudo vim /etc/nginx/conf.d/gitea.conf


server {
    listen 80;

    location / {
        proxy_pass http://localhost:3000;

If using SSL and would like to have http to https redirect, use

server {
	listen 80;
	location / {
        	rewrite     ^$request_uri? permanent;

server {
        listen       443 ssl;
	ssl_certificate /etc/letsencrypt/live/;
	ssl_certificate_key /etc/letsencrypt/live/;

        location / {
            proxy_pass http://localhost:3000;

Replace with your actual domain name.

Restart Nginx service:

sudo systemctl restart nginx

Step 6: Finish Gitea installation on CentOS 8 / CentOS 7

Start the installation by visiting http://domain-name/install

Set database authentication

On the first page, set the database connection

gitea configure mysql ubuntu 18.04 min

The username and password provided should match the ones provided in the Database configuration section. If the database server is on a different host, provide the IP address under the Host section.

Set Application General Settings

Provide application URL, this can be a routable server IP address or domain name that resolves to the IP. The same should be set for SSH.

gitea domain name setting min 1

Disable User self-registration

You can disable User self-registration under “Server and Other Services Settings”. This means the admin user will manually create user accounts.

install gogs git service ubuntu 18.04 disable self registration min

You can optionally create an admin user account. By default, root user will gain admin access automatically.

install gogs git service ubuntu 18.04 configure admin account min

When done with the configurations, click the “Install Gitea” button to finish the installation. On a successful installation, you should be logged into Gitea administration console

gitea login page ubuntu 18.04 min

Refer to Gitea Documentation for advanced configurations and usage guides. Also look at Gitea config cheatsheet.

More guides:

How To Install and Configure GitLab on CentOS 8 / RHEL 8

Gitleaks – How to Audit git repository for secrets

How to Disable User Creation (Signup) on GitLab welcome page

How To Secure GitLab Server with SSL Certificate

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.


Please enter your comment!
Please enter your name here