FedoraRHEL Based

How To Install Gitea on Fedora 38

Install Gitea on Fedora 38

In this tutorial, we will show you how to install Gitea on Fedora 38. For those of you who didn’t know, Gitea is a lightweight, self-hosted Git service that allows teams and individuals to collaborate efficiently and manage version control for their software projects.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of Gitea on a Fedora 38.

Prerequisites

  • A server running one of the following operating systems: Fedora 38.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for Gitea.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Gitea on Fedora 38

Step 1. Before we can install Gitea on Fedora 38, it’s important to ensure that our system is up-to-date with the latest packages. This will ensure that we have access to the latest features and bug fixes and that we can install Gitea without any issues:

sudo dnf update
sudo dnf install git wget curl

Step 2. Installing Gitea on Fedora 38.

By default, Gitea is not available on the Fedora base repository. Now, let’s download and set up the Gitea binary on your Fedora 38 system.

  1. Visit the official Gitea website at https://gitea.io/ and navigate to the downloads page.
  2. Locate the Linux x86-64 binary release and click on the download link.
  3. Once the download is complete, extract the contents of the downloaded archive.

Step 3. Configure Systemd Service.

Create a system user and group to run the Gitea service by executing the following commands:

sudo adduser --system --shell /bin/bash --comment 'Git Version Control' --user-group --home-dir /home/git git

Move the extracted Gitea binary to the appropriate directory and set the required permissions:

sudo mv gitea /usr/local/bin/gitea
sudo chown root:root /usr/local/bin/gitea
sudo chmod 755 /usr/local/bin/gitea

Next, create a systemd service unit file to manage the Gitea service:

nano /etc/systemd/system/gitea.service

Add the following configuration to the file:

[Unit]
Description=Gitea (Git with a cup of tea)
After=syslog.target
After=network.target
After=mysql.service
After=postgresql.service
After=memcached.service
After=redis.service

[Service]
RestartSec=2s
Type=simple
User=git
Group=git
WorkingDirectory=/home/git
ExecStart=/usr/local/bin/gitea web
Restart=always
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/home/git/gitea

[Install]
WantedBy=multi-user.target

Save and close the file.

Step 4. Customize Gitea Configuration.

Now create a directory to store the Gitea configuration files:

sudo mkdir /etc/gitea
sudo chown git:git /etc/gitea

Copy the sample configuration file to the newly created directory:

sudo cp /usr/local/bin/gitea/sample/gitea.ini /etc/gitea/
sudo chown git:git /etc/gitea/gitea.ini

After that, open the Gitea configuration file for editing:

nano /etc/gitea/gitea.ini

Customize the configuration according to your preferences, such as domain settings, database backend, and email configurations. Save the file after making the necessary changes.

Step 5. Setting Up a Database Backend.

Gitea requires a database backend to store its data. In this section, we will cover the steps for setting up MariaDB as the database backend. Now we install and Configure MariaDB:

sudo dnf install mariadb-server mariadb

Once the installation is complete, start the MariaDB service and enable it to automatically start on boot by running the following command below:

sudo systemctl enable mariadb --now
sudo systemctl start mariadb
sudo systemctl status mariadb

To check the version of MariaDB installed, run the command below:

mariadb --version

By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation script. you should read and below each step carefully which will set a root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MariaDB:

mysql_secure_installation

Configure it like this:

- Set root password? [Y/n] y
- Remove anonymous users? [Y/n] y
- Disallow root login remotely? [Y/n] y
- Remove test database and access to it? [Y/n] y
- Reload privilege tables now? [Y/n] y

Next, you will need to create a database and user for Gitea:

mysql -u root -p

Once you are logged in, create a database and user with the following command:

MariaDB [(none)]> CREATE DATABASE gitea;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON gitea.* TO 'gitea_user'@'localhost' IDENTIFIED BY 'your-strong-password';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

For additional resources on installing MariaDB, read the post below:

Step 6. Configuring Web Server and Reverse Proxy.

To access Gitea through a web browser, we need to configure a web server and set up a reverse proxy. In this section, we will use Nginx as the web server. Now we install and Configure Nginx:

sudo dnf install nginx

Once the installation is complete, start the Nginx service and enable it to automatically start on boot by running the following command below:

sudo systemctl start nginx
sudo systemctl enable nginx

Next, create an Nginx server block configuration file for Gitea:

nano /etc/nginx/conf.d/gitea.conf

Add the following configuration to the file:

server {
    listen 80;
    server_name your-domain.com;

    location / {
        proxy_pass http://localhost:3000;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
    }
}

Step 7. Configure SSL Certificate.

To secure the communication with Gitea, we will obtain and configure an SSL certificate using Let’s Encrypt and Certbot. Now we install Certbot and the Nginx plugin:

sudo dnf install certbot python3-certbot-nginx

Obtain an SSL certificate using Certbot:

sudo certbot --nginx --agree-tos --redirect --staple-ocsp --email your_email@example.com -d your-domain.com

Follow the prompts to generate the SSL certificate for your domain.

With the installation and configuration completed, it’s time to start the Gitea service and access it through a web browser:

sudo systemctl enable gitea
sudo systemctl start gitea

Step 8. Configure Firewall.

Fedora comes with Firewalld enabled by default, and it will block other connections from other computers that are trying to access our Gitea service. We must open the appropriate ports so that the Gitea resources can be accessed from other machines:

sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload

You can verify by listing the current firewall settings:

sudo firewall-cmd --permanent --list-all

Step 9. Accessing Gitea Web Interface.

Once successfully installed, open your web browser and access the Gitea Web UI using the URL https://your-domain.com. You will be redirected to the following page:

Install Gitea on Fedora 38

Step 10. Troubleshooting and Additional Resources.

  • In case you encounter any issues during the installation process, refer to Gitea’s official documentation and the Fedora support resources for troubleshooting.
  • Stay updated with the latest versions of Gitea and Fedora by checking their respective websites and release notes.
  • Join the Gitea community forums and discussion boards to connect with other users and seek assistance.
  • Explore advanced configurations and features of Gitea, such as integration with other development tools and customization options.

Congratulations! You have successfully installed Gitea. Thanks for using this tutorial for installing Gitea on your Fedora 38 system. For additional help or useful information, we recommend you check the official Gitea website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button