
Gitea is a simple, lightweight, and self-hosted Git platform written in Go. It is a fork of Gogs and very similar to GitLab. Compared to GitLab, Gitea is extra easy, light-weight, and straightforward to configure. It can be installed on all major operating systems including, Windows, macOS, Linux, and ARM. With Gitea, you can track time, issues, repository branching, file locking, merging, and many more.
In this tutorial, we will show you how to install Gitea with Nginx as a reverse proxy on an Ubuntu 20.04 VPS.
Table of Contents
Prerequisites
- An Ubuntu 20.04 VPS (we’ll be using our SSD 2 VPS plan)
- Access to the root user account (or access to an admin account with root privileges)
Step 1: Log in to the Server & Update the Server OS Packages
First, log in to your Ubuntu 20.04 server via SSH as the root user:
You will need to replace ‘IP_Address’ and ‘Port_number’ with your server’s respective IP address and SSH port number. Additionally, replace ‘root’ with the username of the admin account if necessary.
Before starting, you have to make sure that all Ubuntu OS packages installed on the server are up to date. You can do this by running the following commands:
Step 2: Install Required Dependencies
Before going further, you will need to install some necessary packages on your server. You can install all of them with the following command:
After installing these packages, you can proceed and install the MariaDB server package.
Step 3: Install and Configure MariaDB
Gitea uses MariaDB as a database backend so MariaDB must be installed on your server. You can install it with the following command:
Once MariaDB is installed, connect to the MariaDB shell with the following command:
Once connected, enable the Innodb table using the following command:
Next, create a database and use for Gitea with the following command:
Next, grant all the privileges to gitea database and set character set to utf8mb4:
Next, flush the privileges an exit from the MariaDB with the following command:
Next, edit the MariaDB default configuration file and tweak some settings:
Add the following lines inside [mysqld] section:
Save the file then restart the MariaDB service to apply the changes:
Step 4: Install Gitea
Before downloading and installing Gitea, you will need to create a separate user to run Gitea. You can create a new user with the following command:
After creating a new user, download the latest version of Gitea using the following command:
Once downloaded, copy the downloaded binary to the system path with the following command:
Next, set the execution permission to the gitea binary:
Next, you will need to create a directory structure to store Gitea data and logs. You can create them with the following command:
Next, set proper ownership and permission to all the directories:
Step 5: Create a System Unit File for Gitea
Next, create a systemd service file to manage the Gitea service using systemd.
Add the following lines:
Save and close the file then reload the systemd daemon with the following command:
Next, start the Gitea service and enable it to start at system reboot:
You can also verify the Gitea status with the following command:
Step 6: Configure Nginx as a Reverse Proxy for Gitea
First, install the Nginx package with the following command:
Once installed, you will need to configure Nginx as a reverse proxy to access the Gitea.
First, create a new Nginx virtual host configuration file with the following command:
Add the following lines:
Save and close the file then restart the Nginx service to apply the changes:
Step 7: Access Gitea Web UI
Now, open your web browser and access the Gitea using the URL http://gitea.example.com/install
. You will be redirected to the Gitea setup page:
Provide your Gitea database information, port, URL, admin username, password and click on the Install Gitea button. Once the installation has been finished, you will be redirected to the Gitea dashboard:
Congratulations! you have successfully installed Gitea on Ubuntu 20.04 VPS.
Follow this tutorial if you are looking to install Gitea on Debian 9
Of course, you don’t have to do any of this if you use one of our Git VPS Hosting services, in which case you can simply ask our expert Linux admins to setup this for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.