Gitea Self-Hosted GitHub Alternative
mysql -u root -p
CREATE USER 'gitea' IDENTIFIED BY 'SECRET PASSWORD';
CREATE DATABASE giteadb CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_unicode_ci';
GRANT ALL PRIVILEGES ON giteadb.* TO 'gitea';
FLUSH PRIVILEGES;
# Potentially secure with https://docs.gitea.io/en-us/database-prep/#mysql-1
# Create user
adduser --system --shell /bin/bash --comment 'Git Version Control' --user-group --home-dir /home/git -m git
# Permissions
sudo mkdir -p /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 mkdir /etc/gitea
sudo chown root:git /etc/gitea
sudo chmod 770 /etc/gitea
# Binary
wget -O /usr/local/bin/gitea https://dl.gitea.io/gitea/1.12.3/gitea-1.12.3-linux-amd64
chmod +x /usr/local/bin/gitea
# Systemd
cat << 'EOF' > /etc/systemd/system/gitea.service
[Unit]
Description=Gitea (Git with a cup of tea)
After=network.target
After=mariadb.service
[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
RestartSec=2s
Type=simple
User=git
Group=git
WorkingDirectory=/var/lib/gitea/
ExecStart=/usr/local/bin/gitea web -c /etc/gitea/app.ini
Restart=always
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea
# If you want to bind Gitea to a port below 1024 uncomment
# the two values below
###
#CapabilityBoundingSet=CAP_NET_BIND_SERVICE
#AmbientCapabilities=CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable gitea
systemctl start gitea
# Setup NGINX forwarding
# Navigate to git.stuts.uk/install to setup
cd /var/lib/gitea/custom
mkdir -p templates/custom
cat << EOF > templates/custom/header.tmpl
<link href="https://stuts.uk/gitea.css" rel="stylesheet">
EOF
- The setup for this mentioned changing the password encryption algorithm, worth looking at applying that and migrating existing users for other services in postgres (https://blog.dbi-services.com/migrating-your-users-from-md5-to-scram-authentication-in-postgresql/)
Ref: https://www.vultr.com/docs/how-to-install-gitea-on-centos-7