How to Install Gitea on Ubuntu 20.04

How to Install Gitea on Ubuntu 20.04

How to Install Gitea on Ubuntu 20.04

Gitea is a free, open-source, and lightweight Git hosting solution written in Go. It is designed to be a high-performance alternative to other Git hosting services like GitHub and GitLab, and it can be easily installed on a Linux server. In this article, we will show you how to install Gitea on an Ubuntu 20.04 server.

Prerequisites

How to Install Gitea on Ubuntu 20.04

Before you start the installation, you need to have a clean Ubuntu 20.04 server with a non-root user with sudo privileges. You also need to have the following software installed on your server:

  • Git
  • Go
  • MySQL or PostgreSQL

You can check if Git is installed on your server by running the following command:

  git --version

If Git is not installed, you can install it by running the following command:

  sudo apt update
  sudo apt install git

To install Go, you can follow the instructions in this article: How to Install Go on Ubuntu 20.04.

To install MySQL or PostgreSQL, you can follow the instructions in these articles: How to Install MySQL on Ubuntu 20.04 or How to Install PostgreSQL on Ubuntu 20.04.

Install Gitea

To install Gitea on Ubuntu 20.04, follow the steps below:

  1. Download the latest version of Gitea from the official website. You can download the latest version by running the following command:
          wget https://dl.gitea.io/gitea/1.16.3/gitea-1.16.3-linux-amd64
    
  2. Move the downloaded file to the /usr/local/bin directory:
          sudo mv gitea-1.16.3-linux-amd64 /usr/local/bin/gitea
    
  3. Make the file executable:
          sudo chmod +x /usr/local/bin/gitea
    
  4. Create a user for Gitea:
          sudo adduser --system --shell /bin/bash --group --disabled-password --
    home /home/gitea gitea
    
  5. Create a directory for Gitea’s data:
          sudo mkdir /var/lib/gitea
          sudo chown gitea:gitea /var/lib/gitea
    
  6. Create a Gitea service file:
          sudo nano /etc/systemd/system/gitea.service
    
  7. Paste the following content into the file:
          [Unit]
          Description=Gitea (Git with a cup of tea)
          After=syslog.target
          After=network.target
    ruby
    Copy code
      [Service]
      # Modify these two values and uncomment them if you have
      # repos with lots of files and get an HTTP error 500 because
      # of that
      #LimitMEMLOCK=infinity
      #LimitNOFILE=65535
      User=gitea
      Group=gitea
      WorkingDirectory=/var/lib/gitea
      ExecStart=/usr/local/bin/gitea web -c /etc/gitea/app.ini
      
      [Install]
      WantedBy=multi-user.target
    
  8. Reload the Systemd daemon:
          sudo systemctl daemon-reload
    
  9. Start the Gitea service:
          sudo systemctl start gitea
    
  10. Enable the Gitea service to start on boot:
          sudo systemctl enable gitea
    

Configure Gitea

To configure Gitea, follow the steps below:

  1. Create a configuration file for Gitea:
          sudo mkdir /etc/gitea
          sudo nano /etc/gitea/app.ini
    
  2. Paste the following content into the file:
          [server]
          DOMAIN = localhost
          HTTP_PORT = 3000
          ROOT_URL = http://localhost:3000/
          DISABLE_SSH = false
          SSH_PORT = 22
          START_SSH_SERVER = false
          OFFLINE_MODE = false
          LFS_START_SERVER = false
          LFS_CONTENT_PATH = data/lfs
    java
    Copy code
      [database]
      DB_TYPE = sqlite3
      HOST = 127.0.0.1:3306
      NAME = gitea
      USER = root
      PASSWD = your_password
      SSL_MODE =
    
    disable
    PATH = /var/lib/gitea/gitea.db
    
    java
    Copy code
      [repository]
      ROOT = /var/lib/gitea/repos
      SCRIPT_TYPE = bash
      ANSI_CHARSET = UTF-8
      
      [mailer]
      ENABLED = false
      HOST = 127.0.0.1:25
      FROM = [email protected]
      USER = 
      PASSWD = 
      SSL = false
      TLS = false
      
      [service]
      REGISTER_EMAIL_CONFIRM = false
      ENABLE_NOTIFY_MAIL = false
      DISABLE_REGISTRATION = false
      REQUIRE_SIGNIN_VIEW = false
      ALLOW_ONLY_EXTERNAL_REGISTRATION = false
      ENABLE_CAPTCHA = false
      DEFAULT_KEEP_EMAIL_PRIVATE = false
      DEFAULT_ALLOW_CREATE_ORGANIZATION = true
      NO_REPLY_ADDRESS = noreply.example.com
      ENABLE_SECURITY_FILTER = false
      
      [picture ]
      DISABLE_GRAVATAR = true
      ENABLE_FEDERATED_AVATAR = false
      AVATAR_UPLOAD_PATH = data/avatars
      
      [ log ]
      ROOT_PATH = logs
      
      [session]
      PROVIDER = file
      GC_INTERVAL_TIME = 86400
      
      [attachment]
      PATH = data/attachments
      ALLOWED_TYPES =
      FILE_MAX_SIZE = 32
      UNIT = MB
    
  3. Save the file and exit.

Access the Gitea Web Interface

Once the installation and configuration are complete, you can access the Gitea web interface by browsing to http://your_server_ip:3000. You should see the Gitea login page. To log in, you can use the default administrator account user: admin and password password: admin.

After logging in, you can change the password and customize the settings as needed. Gitea provides a web-based interface that allows you to manage repositories, users, organizations, and access control. It also provides a simple issue tracker and wiki. Additionally, Gitea supports hooks and webhooks, making it easy to integrate with other tools and services.

In this article, we have shown you how to install Gitea on Ubuntu 20.04. You can now host your own Git repositories and collaborate with others on your projects. If you have any questions or comments, feel free to leave them below.

Conclusion

Gitea is a powerful and easy-to-use open-source Git platform that can be installed on your own server. With its simple web interface, you can manage repositories, users, organizations, and access control. Additionally, Gitea provides an issue tracker and wiki, making it a great alternative to other Git hosting platforms.

Installing Gitea on Ubuntu 20.04 is a straightforward process, and by following the steps outlined in this article, you can have your own Git server up and running in no time. Whether you’re working on a personal project or collaborating with others, Gitea can help you keep your code organized and under version control.

If you’re looking for a self-hosted Git platform that provides robust features and ease of use, Gitea is a great option to consider. Give it a try and see for yourself how it can simplify your Git workflow.

Scroll to Top