Gitea is an open-source, self-hosted Git platform that is designed to be lightweight, fast, and easy to use. It is written in the Go programming language and is built on top of the Git version control system. In this article, we will show you how to install Gitea on Rocky Linux 8.
- Before you can install Gitea, you need to make sure that your Rocky Linux 8 system is up to date. Run the following command to update the package index:
sudo dnf update
- Next, you need to install the required dependencies for Gitea. This includes the Git version control system, the Go programming language, and the MariaDB database server. To install these dependencies, run the following command:
sudo dnf install git golang mariadb-server
- After installing the dependencies, start the MariaDB server and enable it to start at boot time by running the following commands:
sudo systemctl start mariadb
sudo systemctl enable mariadb
- With the MariaDB server running, you need to create a database for Gitea. To do this, log in to the MariaDB server as the
root
user by running the following command:
mysql -u root -p
This will prompt you for the password for the root
user. Enter the password, and press Enter
to log in to the MariaDB server.
- Once you are logged in, run the following SQL commands to create a database named
gitea
and a user namedgitea
with the passwordgitea
:
CREATE DATABASE gitea;
CREATE USER 'gitea'@'localhost' IDENTIFIED BY 'gitea';
GRANT ALL PRIVILEGES ON gitea.* TO 'gitea'@'localhost';
- After creating the database and user, exit the MariaDB prompt by running the
exit
command. - Next, you need to download and install Gitea. To do this, open a terminal and navigate to the
/opt
directory by running the following command:
cd /opt
- In the
/opt
directory, download the latest version of Gitea by running the following command:
sudo wget <https://dl.gitea.io/gitea/1.14.3/gitea-1.14.3-linux-amd64>
This will download the Gitea installation package to the /opt
directory.
- After downloading the installation package, extract the downloaded file by running the following command:
sudo unzip gitea-1.14.3-linux-amd64
This will extract the contents of the downloaded file to the /opt
directory.
- After extracting the installation package, rename the extracted directory to
gitea
by running the following command:
sudo mv gitea-1.14.3-linux-amd64 gitea
- With the Gitea installation package extracted and renamed, you need to create a user account for running the Gitea server. To do this, run the following command:
sudo useradd -r -m -d /var/lib/gitea -s /bin/bash gitea
- After creating the
gitea
user account, change the ownership of thegitea
directory to thegitea
user by running the following command:
sudo chown -R gitea:gitea /opt/gitea
- With the ownership of the
gitea
directory changed, you need to create a service unit file for the Gitea server. To do this, create a file namedgitea.service
in the/etc/systemd/system
directory with the following contents:
[Unit]
Description=Gitea (Git with a cup of tea)
After=syslog.target
After=network.target
[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
Type=simple
User=gitea
Group=gitea
WorkingDirectory=/var/lib/gitea
# The default values are pretty good here
ExecStart=/usr/bin/env /opt/gitea/gitea web -c /etc/gitea/app.ini
# These two lines are needed because gitea is not very good at writing PID files
PIDFile=/var/run/gitea.pid
Restart=always
# The default value is pretty good here
# Restart=on-failure
# Uncomment this if you want to run the gitea daemon under another user
# and/or group.
#
# Note that the user and group must already exist.
#
# User=gitea
# Group=gitea
[Install]
WantedBy=multi-user.target
- After creating the
gitea.service
file, enable the Gitea service by running the following command:
sudo systemctl enable gitea
- With the Gitea service enabled, you can now start the Gitea server by running the following command:
sudo systemctl start gitea
Once the Gitea server is started, open a web browser and navigate to http://localhost:3000/
to access the Gitea web interface. This will bring up the Gitea login page, where you can log in to your Gitea account.
Congratulations! You have successfully installed Gitea on Rocky Linux 8. You can now use Gitea to host your Git repositories and manage your codebase.