Gitea is a Github-like open-sourced version management software. It's arguably the simplest, quickest, most peaceful way to get a self-hosted Git system up and running. Gitea is indeed a Gogs replica that is entirely available and free to use.
In this context, we shall look into how to set up Gitea rapidly and effortlessly on Ubuntu 20.04.
How to Install Gitea on Ubuntu ?
Before proceeding with this Installation procedure, you need to have sudo rights on the user.
Then follow the steps given below.
1. Update Apt Package
Open and log in from the Ubuntu 20.04 system first. Use "Ctrl+Alt+T" to launch the terminal. Make sure to update your apt package first by running the following command:
$ sudo apt update
When prompted, Add the sudo account passcode, to continue.
2. Install Git
Now, you have to first install git with certain more packages on your system. For this reason, try out the below installation apt command using the sudo privileges:
$ sudo apt install git unzip gnupg2
Now, the git has been installed, it’s time to generate a new Git user for the execution of Gitea facilities on your system. Hence you have to add the below query in the shell to do so:
$ sudo adduser –system –group –disabled-password –shell /bin/bash –home /home/git –gecos 'Git Version Control' git
3. Deploy MariaDB
To keep its information, Gitea needs a database server. And if you're searching for something like an open-source content management server, MariaDB is a wonderful opportunity to look. Execute the command underneath to set up MariaDB:
$ sudo apt-get install mariadb-server mariadb-client
Now, Affirm the installation of MariaDB by tapping "Y" for yes in the shell as asked.
The instructions beneath could be used to quit, begin, and enable MariaDB to ever kickstart whenever the server starts up once it has been installed:
$ sudo systemctl enable mariadb.service
$ sudo systemctl start mariadb.service
$ sudo systemctl stop mariadb.service
Then, to protect the MariaDB server, use the instructions underneath to create a root password as well as disable global root access:
$ sudo mysql_secure_installation
As we don't want to change the password for the root user, hence we pressed "n".
To avoid removing anonymous users, press "n".
To disable remote login from root user, tap "n".
To avoid removing the test database, hit "n".
To avoid reloading tables, tap "n".
4. Set Up MariaDB
Execute the instruction underneath to connect to the MariaDB database:
$ sudo mysql –u root –p
Now set the value of "innodeb_file_per_table" to "ON":
SET GLOBAL innodeb_file_per_table = ON;
Make a new DB, named "giteadb":
CREATE DATABASE giteadb;
Make a new user named "giteauser":
CREATE USER 'giteauser'@'localhost' IDENTIFIED BY 'new_password';
Give full privileges access to this user:
GRANT ALL ON giteadb.* TO 'giteauser'@'localhost' IDENTIFIED BY 'new_password' WITH GRANT OPTION;
You can modify the character set of your database "giteadb":
ALTER DATABASE giteadb CHARACTER SET = utf8mb4 COLLATE utf8mb4_unicode_ci;
Save your updates and quit:
Now you have to open the configuration file of MariaDB to update it a little. Use the below sudo command to edit it in a nano editor:
$ sudo nano /etc/mysql.mariadb.conf.d/50-server.cnf
Now add the below appended script at the end of the configuration file. Press Ctrl+S to save the changes and leave the file via Ctrl+X.
Now, restart MariaDB once again:
$ sudo systemctl restart mariadb.service
$ sudo systemctl restart mysql.service
5. Install Gitea:
Move to the "tmp" folder, then use the wget command to download "Gitea":
$ cd /tmp
$ wget https://dl.gitea.io/gitea/1.8.0/gitea-1.8.0-linux-amd64
Move the file to '/usr/local/bin', and change it to executable using "Chmod":
$ sudo mv gitea-1.8.0-linux-amd64 /usr/local/bin/gitea
$ sudo chmod +x /usr/local/bin/gitea
Open the "gitea.service" file:
$ sudo nano /etc/system/system/gitea.service
Add the below script, save and close it
Now you have to reload your system and enable GItea services:
$ sudo systemctl daemon-reload
$ sudo systemctl enable gitea
Start the Gitea service and check its status:
$ sudo systemctl start gitea
$ sudo systemctl status gitea