Install gitea
Install MariaDB server
Get the package with the package manager
apt install mariadb-server
Create MySQL gitea user and gitteadb database
mysql
CREATE USER 'gitea'@'localhost' IDENTIFIED BY 'PASSWORD';
CREATE DATABASE giteadb;
GRANT ALL PRIVILEGES ON giteadb.* TO 'gitea'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Download and and prepare gitea
Download the correct newest version from dl.gitea.com/gitea, e.g.:
wget -O gitea https://dl.gitea.com/gitea/1.21.5/gitea-1.21.5-linux-amd64
Then copy it to /usr/local/bin/gitea and make it excecutable:
cp gitea /usr/local/bin/gitea
chmod +x /usr/local/bin/gitea
Ensure the git user exists
adduser --system --shell /bin/bash --gecos 'Git Version Control' --group --disabled-password --home /home/git git
Create gitea directories:
mkdir -p /var/lib/gitea/{custom,data,log}
chown -R git:git /var/lib/gitea/
chmod -R 750 /var/lib/gitea/
mkdir /etc/gitea
chown root:git /etc/gitea
chmod 770 /etc/gitea
Create daemon file into /etc/systemd/system/gitea.service :
[Unit]
Description=Gitea (Git with a cup of tea)
After=syslog.target
After=network.target
Wants=mysql.service
After=mysql.service
[Service]
# Uncomment the next line if you have repos with lots of files and get a HTTP 500 error because of that
# LimitNOFILE=524288:524288
RestartSec=2s
Type=simple
User=git
Group=git
WorkingDirectory=/var/lib/gitea/
ExecStart=/usr/local/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
Register and start daemon
systemctl enable gitea
systemctl start gitea
The server should run now on port 3000. Access the page to finish the configuration.
Make sure the user git is allowed to connect to the server via SSH (check /etc/ssh/sshd_config for Allowed* entries and compare to the username and group).