Setup Gitea on Ubuntu in Azure/AWS/GCP

Setup and install Gitea on Ubuntu 22.04.  Gitea is a lightweight, self-hosted Git service that provides a simple and powerful platform for managing Git repositories, project collaboration, and code review. An alternative to GitHub, GitLab, and Bitbucket. Built to be fast and easy to set up, Gitea offers a web-based interface for repository hosting and management, making it ideal for teams of all sizes.  Deploy on any of the cloud IaaS platforms using our Gitea server image from the marketplace. Deployment links below.

Cloud Gitea Self-Hosted

Gitea on Azure

Gitea Azure

Deploy Gitea on Ubuntu 22.04 on Azure

Gitea on AWS

Coming soon..

Gitea on GCP

Coming soon..

Getting Started with Gitea Server

Once your Gitea server has been deployed, the following links explain how to connect to a Linux VM:

 

 

Once connected and logged in, the following section explains how to start using Gitea server.

Setup Gitea MySQL Database

Step 1: Set MySQL Root Password

First step is to set the MySQL root password:

				
					sudo mysql_secure_installation

				
			

This command will guide you through a series of prompts:

 

  • Set root password: If you haven’t set a password, it will prompt you to do so. The current password is blank, simply hit enter when it asks for the current password.
  • Other security-related options: You can choose to remove anonymous users, disable root login remotely, and remove the test database.

Step 2: Create a Gitea Database and User

After setting the MySQL root password, follow these steps to create a dedicated database and user for Gitea:

 

  1. Log in to MySQL:
				
					sudo mysql -u root -p

				
			

2. Create a database for Gitea:

				
					CREATE DATABASE gitea;

				
			

3. Create a user for Gitea and grant privileges: Replace <password> with a secure password for the Gitea user.

				
					CREATE USER 'giteauser'@'localhost' IDENTIFIED BY '<password>';
GRANT ALL PRIVILEGES ON gitea.* TO 'giteauser'@'localhost';
FLUSH PRIVILEGES;

				
			

4. Exit MySQL:

				
					EXIT;

				
			

Accessing Gitea Web Interface

Once Gitea is running, you can access the web interface using a browser.

 

  1. Open a browser and go to:
				
					http://<your-server-ip>:3000

				
			
  • Replace <your-server-ip> with the public or private IP address of your server.

 

2. Initial Setup Screen:

    • The first time you access Gitea, you will see the Initial Setup screen. Here, you can configure basic settings.

Initial Configuration of Gitea

On the Initial Configuration page, you need to set up some essential settings for Gitea:

Gitea setup

2.1 Database Settings:

  • Database Type: Choose MySQL (MariaDB).
  • Host: 127.0.0.1:3306
  • Database Name: gitea
  • User: giteauser
  • Password: The MySQL giteauser user password we created earlier.
  • SSL Mode: disable (unless you’re using SSL for the database connection).

2.2 Repository Settings:

  • Repository Root Path: /var/lib/gitea/data/gitea-repositories
  • LFS Path: /var/lib/gitea/data/lfs

2.3 Server Settings:

  • Domain: <your-server-ip or domain>
  • HTTP Port: 3000
  • Application URL: http://<your-server-ip>:3000/
    • Replace <your-server-ip> with your server’s IP address or domain.

2.4 Administrator Account:

  • Username: Choose an admin username (e.g., giteaadmin).
  • Password: Set a strong password.
  • Email: Provide an admin email address.

 

After filling out the settings, click Install Gitea. This will finalize the configuration and set up your Gitea instance.

Logging In and User Management

  1. Admin Login: Once Gitea is configured, log in using the administrator credentials you created during setup.

 

2. User Registration:

    • By default, new users can self-register. They can click Register on the login page and create their own account.
    • You can disable self-registration in the Admin Panel if needed.
Gitea Admin Login

Creating a Repository

Repositories in Gitea can be created by any registered user. Here’s how to create a repository:

 

  1. Log in to Gitea.
  2. Click New Repository from the dashboard.
  3. Fill in the repository details:
      • Repository Name: Give your repository a name.
      • Description: Optionally, provide a description for your repository.
      • Public/Private: Choose whether to make the repository public or private.
      • Initialize with README: You can initialize the repository with a README file.
  4. Click Create Repository.

 

Once the repository is created, you’ll be given a Git URL to clone it to your local machine:

				
					git clone http://<your-server-ip>:3000/<username>/<repository-name>.git

				
			
Creating a new repo

Enabling SSL (Optional)

To enhance security, you can enable SSL on Gitea. Here’s a basic outline for enabling SSL:

 

  1. Obtain an SSL certificate (via Let’s Encrypt or another provider).

2. Update Gitea configuration:

    • Edit the Gitea configuration file (/etc/gitea/app.ini).
    • In the [server] section, update the following:
				
					PROTOCOL = https
CERT_FILE = /path/to/ssl/cert.crt
KEY_FILE = /path/to/ssl/private.key

				
			

Restart Gitea:

				
					sudo systemctl restart gitea

				
			

You can now access Gitea over HTTPS.

Troubleshooting

If you encounter any issues, you can check Gitea logs for more information:

  1. Systemd Logs:
				
					sudo journalctl -u gitea

				
			

2. Gitea Application Logs: Check the logs located in /var/lib/gitea/log.

Default Gitea Ports

  1. HTTP (Web Interface): 3000 (default)
    • This is the default port used for accessing the Gitea web interface over HTTP.
    • URL: http://<your-server-ip>:3000

 

2. HTTPS (Web Interface): Custom (if configured)

    • If you configure SSL for Gitea, you can change this to an appropriate HTTPS port, commonly 443.

 

3. SSH for Git: 22 (default SSH port)

    • Gitea allows SSH access for cloning, pushing, and pulling Git repositories via SSH.
    • You can configure Gitea to use a different port for SSH if needed.

The links below explain how to modify / create firewall rules depending on which cloud platform you are using.

 

To setup AWS firewall rules refer to – AWS Security Groups

To setup Azure firewall rules refer to – Azure Network Security Groups

To setup Google GCP firewall rules refer to – Creating GCP Firewalls

Documentation / Support

Refer to Gitea official documentation on tutorials and support information:

 

https://docs.gitea.com/

 

If you need assistance with getting your VM setup and working please contact us for support requests.

Disclaimer: Gitea is licensed under the MIT License. The license comes with a “no warranty” clause, meaning the software is provided “as-is” without any guarantees or liability for issues that may arise.

Avatar for Andrew Fitzgerald
Andrew Fitzgerald

Cloud Solution Architect. Helping customers transform their business to the cloud. 20 years experience working in complex infrastructure environments and a Microsoft Certified Solutions Expert on everything Cloud.

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x