Setting up a Gitea server
Set up a MYSQL Database
Make sure you are listening on 0.0.0.0 and not localhost.
CREATE DATABASE gitea_db;
CREATE USER 'gitea_admin'@'you network IP' IDENTIFIED BY 'not saying';
GRANT ALL PRIVILEGES ON gitea_db.* TO 'gitea_admin'@'you network IP' WITH GRANT OPTION;
Gitea Setup
# Get Software
wget -O gitea https://dl.gitea.com/gitea/1.23.7/gitea-1.23.7-linux-amd64
# Add Git User
sudo adduser --system --shell /bin/bash --gecos 'Git Version Control' --group --disabled-password --home /home/git git
# Link to RAID
sudo ln -s /var/lib/gitea /mnt/RAID/gitea
#Make Directory structure
sudo mkdir -p /var/lib/gitea/{custom,data,log}
sudo chown -R git:git /var/lib/gitea/
sudo chmod -R 750 /var/lib/gitea/
sudo mkdir /etc/gitea
sudo chown root:git /etc/gitea
sudo chmod 770 /etc/gitea
Gitea Service
Create a service to run in /etc/systemd/system/gitea.service
[Unit]
Description=Gitea (Git with a cup of tea)
After=network.target
[Service]
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
Gitea initial setup
I needed this because 3000 is in use. You put this file in /etc/gitea/app.ini
[server]
PROTOCOL = http
DOMAIN = localhost
ROOT_URL = %(PROTOCOL)s://%(DOMAIN)s:%(HTTP_PORT)s/
HTTP_ADDR = 0.0.0.0
HTTP_PORT = 1701
DISABLE_SSH = false
Nginx Setup
Need to add a reverse proxy
server{
server_name git.example.local;
listen 443 ssl;
access_log /var/log/nginx/git.example.local.log;
error_log /var/log/nginx/git.example.local.log error;
disable_symlinks off;
ssl_certificate /etc/ssl/certs/server.crt;
ssl_certificate_key /etc/ssl/private/server.key;
client_max_body_size 20m;
location ~ / {
client_max_body_size 512M;
proxy_pass http://localhost:1701;
proxy_set_header Connection $http_connection;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}