Install Gitea Code Hosting Service on Oracle Linux

This article will go through how to install Gitea Code Hosting Service on Oracle Linux. Gitea is a community-managed lightweight code hosting solution written in Go and published under the MIT license. It is a simple self-hosted Git service, similar to GitHub, Bitbucket, and GitLab.

How to Install Gitea Code Hosting Service on Oracle Linux

  • Update Oracle Linux packages using the command below.
sudo dnf update -y
  • Install the following dependencies.
sudo dnf install git unzip gnupg2 nano mariadb-server wget -y
  • Start MariaDB.
sudo systemctl start mariadb
  • Enable MariaDB to start on system boot.
sudo systemctl enable mariadb
  • Secure MySQL by running the command below.
sudo mysql_secure_installation

Sample output

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] n
 ... skipping.

You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n] n
 ... skipping.

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
  • After securing MariaDB, log in to its shell using the following command.
sudo mysql -u root -p
  • Create a Gitea database.
CREATE DATABASE gitea;
  • Then create gitea database user with your preferred password.
GRANT ALL PRIVILEGES ON gitea.* TO 'gitea'@'localhost' IDENTIFIED BY "YourStrongPassword";
  • Flush all privileges.
FLUSH PRIVILEGES; 
  • Exit the MariaDB shell using the command below.
exit

Install Gitea Code Hosting Service on Oracle Linux

  • Start by downloading Gitea latest version from the download page using wget command to /usr/bin/gitea directory.
sudo wget -O /usr/bin/gitea https://dl.gitea.io/gitea/1.17.3/gitea-1.17.3-linux-amd64
  • Next, change the downloaded file permission.
sudo chmod +x /usr/bin/gitea
  • To check the Gitea version installed run the command below.
gitea --version
  • Create a Git user.
sudo useradd --system --shell /bin/bash --comment 'Git Version Control' --create-home --home /home/git  git
  • Then create Gitea directories.
sudo mkdir -pv /var/lib/gitea /{custom,data,indexers,public,log}
  • Change Gitea directory ownership.
sudo chown -Rv git:git /var/lib/gitea
  • Change its permissions using the following command.
sudo chmod -Rv 750 /var/lib/gitea
  • Create a configuration directory.
sudo mkdir -v /etc/gitea
  • Change the configuration directory ownership using the command below.
sudo chown -Rv root:git /etc/gitea
  • Then use the command below to change its permissions.
sudo chmod -Rv 770 /etc/gitea

Create Systemd service file for Gitea

  • Use the following command to create a Systemd service file.
sudo nano /etc/systemd/system/gitea.service

Paste the configuration below. Save and close the file.

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

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

ExecStart=/usr/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
  • Next start Gitea and enable it to run on system boot using the following command.
sudo systemctl enable --now gitea

Access Gitea Web Interface

  • Open your web browser then enter your server IP or domain name followed by port 3000 to access Gitea e.g. http://127.0.0.1:3000 . Enter your database name and password for Gitea.
Install Gitea Code Hosting Service on Oracle Linux
Install Gitea Code Hosting Service on Oracle Linux
  • At the end of the page click on the Install Gitea button to complete the installation.
Install Gitea Code Hosting Service on Oracle Linux
Install Gitea Code Hosting Service on Oracle Linux
  • After the installation, the home page will be displayed. Alternatively, to access it, enter your domain name followed by port 3000.
Install Gitea Code Hosting Service on Oracle Linux
Install Gitea Code Hosting Service on Oracle Linux
  • That concludes our tutorial on how to install Gitea Code Hosting Service on Oracle Linux.

Read more on Gitea Documentation

Other Tutorials

Install Rust on OpenSUSE

Install AIDE on Rocky Linux 9

Install KDE Desktop Environment on Rocky Linux 9

System administrator | Software Developer | DevOps

Leave a Comment