How to install the self-hosted Git server Gitea on Ubuntu 18.04

Need an on-premises git repository? Look no further than Gitea. Jack Wallen shows you how to install this feature-rich tool.

How to install the self-hosted Git server Gitea on Ubuntu 18.04

If you're a developer, and you'd like to host a Git server on your internal company LAN, there are a number of solutions out there. One such solution is the open source Gitea. Written in Go, Gitea includes a repository file editor, project issue tracking, users managements, notifications, built-in wiki, and more. 

Gitea can be deployed on nearly any platform, but I want to show you how to do so on Ubuntu Server 18.04.

SEE: Serverless computing: A guide for IT leaders (TechRepublic Premium)

What you'll need

  • A running instance of an updated Ubuntu Server 18.04

  • A user with sudo privileges

How to install Git

The first thing that must be done is the installation of Git. I will assume you've already upgraded your Ubuntu server. With that out of the way, install git with the command:

sudo apt-get install git -y

Next, create a system user, named git, that will be used to run the Gitea application. This is accomplished with the command:

sudo adduser --system --group --disabled-password --shell /bin/bash --home /home/git --gecos 'Git Version Control' git

Visit the Gitea download page and check the release number for the latest current version. As of this writing, the latest version is 1.11.3. Download the latest version with the command:


Make sure to download the latest version that matches the architecture for your server.

Change the name of the downloaded binary with the command:

mv gitea-1.11.3-linux-amd64 gitea

Give the downloaded binary executable permissions with the command:

chmod ugo+x gitea

Move the gitea binary into the /usr/local/bin directory with the command:

sudo mv gita /usr/local/bin

Next, we need to create a few directories and set the proper permissions with the following commands:

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

Gitea depends on a systemd unit file. Fortunately, the developers have made one available. Download this file with the command:

sudo wget -P /etc/systemd/system/

Once that file has downloaded, you need to make one simple change. Open the file for editing with the command:

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

In that file, look for the line:


Change that to:


Save and close the file.

Enable and start the service with the commands:

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

How to install and configure the database

Gitea does rely on a database. For this, we'll install and use the MariaDB server. Install this with the command:

sudo apt-get install mariadb-server -y

Create a database admin password and secure the server with the command:

sudo mysql_secure_installation

Log in to the database console with the command:

sudo mysql -u root -p

Create a database admin password and secure the server with the command:

sudo mysql_server_installation

Once you've taken care of that, log in to the database console with the command:

sudo mysql -u root -p

Create the database with the command:


Grant the necessary permissions with the command:


Where PASSWORD is a strong/unique password.

Finish up the database with the commands:


How to configure and finish the installation

Gitea is now installed and running, but still needs a bit of configuration. Open a web browser and point it to http://SERVER_IP:3000 (where SERVER_IP is the IP address of your hosting server). You should see the Gitea main page (Figure A).

Figure A


The Gitea main page.

Click Register and you'll be presented with the Initial Configuration page (Figure B).

Figure B


The Gitea Initial Configuration page.

Make sure to use the database details from the database you created above. Once you've filled everything out, click Install Gitea (Figure C).

Figure C


Finishing up the installation.

When the installation completes, you'll be presented with the user registration page (Figure D).

Figure D


Registering a user for Gitea.

And that's it. Gitea is now installed. You can begin using it as your on-premises Git repository server.

Also see

Programmer working in a software developing company office

Image: iStockphoto/nd3000

By Jack Wallen

Jack Wallen is an award-winning writer for TechRepublic, The New Stack, and Linux New Media. He's covered a variety of topics for over twenty years and is an avid promoter of open source. For more news about Jack Wallen, visit his website jackwallen....