Gitea is a lightweight, easy-to-use Git server written in Go.
Its main features include:
- Repository file editor
- Project issue tracking
- User management
- Notifications
- Built-in wiki
- Small memory footprint
- Alternative to Gitlab
Prepare the server
Start by updating your system's package repository to the latest version.
You can do this with the following command:
# apt update && apt upgrade -yNext, install the MariaDB database server:
# apt install mariadb-serverOnce installed, log in to mysql as root:
# mysql -u root -pYou will need to create the database user and grant the appropriate privileges:
MariaDB [(none)]>CREATE DATABASE gitea;
MariaDB [(none)]>GRANT ALL PRIVILEGES ON gitea.* to 'gitea'@'localhost' IDENTIFIED BY 'Contraseña';
MariaDB [(none)]>FLUSH PRIVILEGES;
MariaDB [(none)]>exit;Install Gitea
First, add the git user
adduser --system --shell /bin/bash --gecos 'Git Version Control' --group --disabled-password --home /home/git gitOn the download page for Gitea, check the latest version available to download; in this case, it is 1.22
wget https://dl.gitea.com/gitea/1.22/gitea-1.22-linux-amd64Move the binary to the appropriate directory:
# mv gitea-1.22-linux-amd64 /usr/bin/gitea
# chmod 755 /usr/bin/giteaCreate the necessary directories and set the appropriate permissions:
# mkdir -p /etc/gitea /var/lib/gitea/{custom,data,indexers,public,log}
# chown git:git /etc/gitea /var/lib/gitea/{custom,data,indexers,public,log}
# chmod 750 /var/lib/gitea/{data,indexers,log}
# chmod 770 /etc/giteaCreate the Systemd service file for Gitea
Next, create a systemd service file to manage the Gitea service. You can do this with the following command:
# nano /etc/systemd/system/gitea.serviceAdd the following lines:
[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.targetSave and close the file. Then reload the systemd daemon with the following command:
# systemctl daemon-reloadNext, start the Gitea service and enable it to start at boot with the following commands:
# systemctl start gitea
# systemctl enable giteaYou can now check the status of the Gitea service with the following command:
# systemctl status giteaIf everything is working correctly, you should see the following output:
● gitea.service - Gitea
Loaded: loaded (/etc/systemd/system/gitea.service; enabled; preset: enabled)
Active: active (running) since Mon 2024-05-06 14:00:18 CEST; 7s ago
Main PID: 5966 (gitea)
Tasks: 6 (limit: 2276)
Memory: 105.1M (peak: 105.4M)
CPU: 654ms
CGroup: /system.slice/gitea.service
└─5966 /usr/bin/gitea web --config /etc/gitea/app.ini
May 06 14:00:18 giteagit gitea[5966]: 2024/05/06 14:00:18 cmd/web.go:111:showWebStartupMessage() [I] Gitea version: 1.22.0+rc1-39-gb22d7fd8cd built with GNU Make 4.3, go1.22.2 : bindata, sql>
May 06 14:00:18 giteagit gitea[5966]: 2024/05/06 14:00:18 cmd/web.go:112:showWebStartupMessage() [I] * RunMode: prod
May 06 14:00:18 giteagit gitea[5966]: 2024/05/06 14:00:18 cmd/web.go:113:showWebStartupMessage() [I] * AppPath: /usr/bin/gitea
May 06 14:00:18 giteagit gitea[5966]: 2024/05/06 14:00:18 cmd/web.go:114:showWebStartupMessage() [I] * WorkPath: /var/lib/gitea
May 06 14:00:18 giteagit gitea[5966]: 2024/05/06 14:00:18 cmd/web.go:115:showWebStartupMessage() [I] * CustomPath: /var/lib/gitea/custom
May 06 14:00:18 giteagit gitea[5966]: 2024/05/06 14:00:18 cmd/web.go:116:showWebStartupMessage() [I] * ConfigFile: /etc/gitea/app.ini
May 06 14:00:18 giteagit gitea[5966]: 2024/05/06 14:00:18 cmd/web.go:117:showWebStartupMessage() [I] Prepare to run install page
May 06 14:00:18 giteagit gitea[5966]: 2024/05/06 14:00:18 cmd/web.go:304:listen() [I] Listen: http://0.0.0.0:3000
May 06 14:00:18 giteagit gitea[5966]: 2024/05/06 14:00:18 cmd/web.go:308:listen() [I] AppURL(ROOT_URL): http://localhost:3000/
May 06 14:00:18 giteagit gitea[5966]: 2024/05/06 14:00:18 ...s/graceful/server.go:50:NewServer() [I] Starting new Web server: tcp:0.0.0.0:3000 on PID: 5966Access Gitea
Gitea is now installed and configured. It is time to access the Gitea web interface.
All that remains is to open the port in the Clouding firewall:
Open your web browser and enter the URL http: // your-server-ip:3000 / install. You will be redirected to the Gitea installation wizard, as shown below:
If you want to use Gitea with a custom domain, you can change the Gitea Base URL field to the domain you want to use. In our case, we leave the default IP address (you can also make these changes later in the /etc/gitea/app.ini file by modifying domain and root URL):
If you also want to use your own domain and serve Gitea directly over HTTPS without a specific port, you can do so using a proxy with Nginx.
Now provide all the required information, such as the database name, database username, Gitea URL, and Gitea administrator username and password. Then click the ‘Instalar Gitea’ button. Once installation is complete, you can create an account and start using Gitea:
Remember, if you have any questions about this or anything else related to your servers on Clouding, feel free to email soporte@clouding.io. We are here to help with whatever you need. Get in touch!