| by Arround The Web | No comments

A Complete Guide to Install Gitea on Ubuntu 22.04

Gitea is a top notch open-source self-hosted Git server similar to GitLab written in the Go language. However, it is more straightforward, lightweight and easy to configure as compared to GitLab. It includes various features such as notification, repository file editor, user management and much more.

The tutorial provides the simple guidelines to install Gitea on Ubuntu 22.04 LTS.

A Complete Guide to Install Gitea on Ubuntu 22.04

The following is the step-by step guidelines that will let you install Gitea on Ubuntu 22.04:

Step 1: Update System Packages

First, update the system packages using the following command:

$ sudo apt update

Step 2: Install Wget

After the update, you will require wget to install Gitea binary through the command line. You can install wget using the following command:

$ sudo apt install wget

Step 3: Install Git

You will also require to install Git on Ubuntu by running the following command:

$ sudo apt install git

Step 4: Install and Configure MariaDB server

Gitea can work with any server whether it’s MySQL, SQLLite3 or MariaDB. You can install any database management system you want. Here, we are using MariaDB.

To install it on Ubuntu, use the following command:

$ sudo apt install mariadb-server

Step 5: Create Gitea Database

To create Gitea Database, you will first need to login to MariaDB server with the default username and password using the following command:

$ sudo mysql -u root -p

Then, create a database using the following statement:

CREATE DATABASE gitea;

Next, use the following statement to create username and password.

GRANT ALL PRIVILEGES ON gitea.* TO 'gitea'@'localhost' IDENTIFIED BY "<Type_Your_Password>";

In the end, issue the below-given statements to complete mySQL set up.

FLUSH PRIVILEGES;
QUIT;

Step 6: Install Gitea

After completing the mySQL setup, its now time to install Gitea on Ubuntu using the following command:

$ sudo wget -O /usr/local/bin/gitea https://dl.gitea.io/gitea/1.16.7/
gitea-1.16.7-linux-amd64

Now, make the gitea file executable using the following command:

$ sudo chmod +x /usr/local/bin/gitea

This will complete the installation of Gitea on Ubuntu 22.04.

You can check the Gitea version via below-given command:

$ gitea --version

Step 7: Add a new user

Next, add a new user git via the below-mentioned command:

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

The above command will create a new user.

Next, make some important Gitea’s directories using the following command:

$ sudo mkdir -pv /var/lib/gitea/{custom,data,log}

Then modify ownership of the above directories through below-given command:

$ sudo chown -Rv git:git /var/lib/gitea

After that you have to fix the correct permission to the Gitea directory through below-mentioned command:

$ sudo chmod -Rv 750 /var/lib/gitea

Then, you will require to create configuration directory of Gitea in the location “/etc/gitea” using the following command:

$ sudo mkdir -v /etc/gitea

Next, replace the user Gitea with root and group with the git in the configuration directory using the below-given command:

$ sudo chown -Rv root:git /etc/gitea

Now allows changing the permission to the configuration directory via following command:

$ sudo chmod -Rv 770 /etc/gitea

Step 8: Creating Systemd service file

After the above steps are completed, you will then be required to create a Systemd service file with the name “gitea.service” in the directory location “/etc/system/system/”.

In order to create a file for Gitea, run the following command to open a file editor:

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

Then paste the following texts into the file.

[Unit]
Description=Gitea
After=syslog.target
After=network.target

RestartSec=3s
Type=simple
User=git
Group=git
WorkingDirectory=/var/lib/gitea/

ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini
Restart=always
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea

[Install]
WantedBy=multi-user.target

Save the file by pressing the “Ctrl+X” key and choose Y then press Enter.

Now restart the Gitea service through following command:

$ sudo systemctl start gitea

You can check the Gitea status through following command:

$ sudo systemctl status gitea

Next, you will also need to enable the Gitea service through the following command so that the service will automatically start after the reboot.

$ sudo systemctl enable gitea

Now open your web browser on Ubuntu and use the address http://<Ubuntu_IP_Address>:3000. To check your system IP address, you can use the following command:

$ hostname -I

The above address will open the Gitea on the browser.

Go to the “Register” option by clicking at the top left corner.

Create an account on Gitea server and start using its services on Ubuntu 22.04.

The above screen appears when you successfully Register an account on Gitea server and this ends the installation of Gitea on Ubuntu 22.04.

In case, if you need guidance on using Gitea server, you can get help from its documentation.

Conclusion

Gitea is an open-source, widely used self-hosted Git server that is more lightweight and simpler to configure than Gitlab. The above instructions will help you install Gitea on Ubuntu 22.04 so that you may be able to enjoy its features such as repository management, web-based file upload and creation, code review and much more.

Share Button

Source: linuxhint.com

Leave a Reply