Hosting your own code repositories is a great way to keep your projects private. Gitea is a lightweight Git service written in Go. It is very fast, uses very little memory, and provides a clean web interface that works just like GitHub.
Gitea is much lighter than GitLab or other self-hosted options. It runs easily on cheap cloud servers or home computers.
This guide will show you how to install Gitea on Ubuntu 18.04 and configure it for production.
Gitea requires a database to store its data. We will use MariaDB, which is an open source database system.
First, update your package index and install Git, MariaDB, and Nginx:
bashsudo apt updatesudo apt install git mariadb-server nginx
Once the database is installed, secure it by running:
bashsudo mysql_secure_installation
Follow the prompts to set a database root password and remove test settings.
Log in to the database shell:
bashsudo mysql -u root -p
Create a database and a dedicated user for Gitea. Make sure to use a strong password:
sqlCREATE DATABASE gitea CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;GRANT ALL PRIVILEGES ON gitea.* TO 'gitea'@'localhost' IDENTIFIED BY 'StrongPassword';FLUSH PRIVILEGES;EXIT;
Gitea should not run with administrative privileges. Create a system user named git:
bashsudo adduser --system --group --disabled-password --shell /bin/bash --home /home/git --gecos 'Git Version Control' git
Now, download the Gitea binary. Look for the latest version on the official site. Download it to your server:
bashwget -O /tmp/gitea https://dl.gitea.io/gitea/1.21.0/gitea-1.21.0-linux-amd64sudo mv /tmp/gitea /usr/local/bin/giteasudo chmod +x /usr/local/bin/gitea
Create the folders Gitea needs and set the owner permissions so the git user can write to them:
bashsudo mkdir -p /etc/gitea /var/lib/gitea/{custom,data,indexers,public,log}sudo chown git:git /var/lib/gitea/{data,indexers,log}sudo chmod 750 /var/lib/gitea/{data,indexers,log}sudo chown root:git /etc/giteasudo chmod 770 /etc/gitea Create a system file to manage Gitea in the background:
bashsudo nano /etc/systemd/system/gitea.service
Paste these configuration lines into the file:
ini[Unit]Description=GiteaAfter=syslog.target network.target mysql.service[Service]RestartSec=2sType=simpleUser=gitGroup=gitWorkingDirectory=/var/lib/gitea/ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.iniRestart=always[Install]WantedBy=multi-user.target
Save the file. Enable and start Gitea:
bashsudo systemctl enable giteasudo systemctl start gitea
Open your web browser and navigate to your server’s IP address on port 3000:
<code>http://your_server_ip:3000</code>
The setup page will open. Enter your MariaDB database details and configure your admin account. Once the setup is complete, lock down your config folder:
bashsudo chmod 750 /etc/giteasudo chmod 640 /etc/gitea/app.ini
Gitea is now running on your server. You can create users, set up repositories, and sync your projects. Leave a comment below if you have any questions.
Running programs built for Microsoft's framework on a Linux system is easier than you think. Mono is…
Computer vision technology powers many modern applications, from image editors to facial scanners. OpenCV (Open Source Computer…
A remote desktop interface makes it easy to manage a remote computer. VNC (Virtual Network Computing) is…
Many modern programs require Java to run. From development tools like Eclipse to search systems…
Setting a static IP address on your server is a smart move. It ensures your…
Xrdp is an open-source implementation of the Microsoft Remote Desktop Protocol (RDP). It lets you access…