Before we start, you will need a Debian 10 VPS (you can get one on digitalocean for example), if you prefer to use your own self hosted server, make sure that port 80 and 443 are correctly port forwarded so that the public ip points to the server and not the router. Once that's done, go and ssh into your debian 10 server.
adduser --system --shell /bin/bash --group --disabled-password --home /home/git git
wget -O /usr/local/bin/gitea https://dl.gitea.io/gitea/1.12.5/gitea-1.12.5-linux-amd64
chmod +x /usr/local/bin/gitea
./gitea
mkdir -p /var/lib/gitea/{custom,data,indexers,public,log}
chown git:git /var/lib/gitea/{data,indexers,log}
chmod 750 /var/lib/gitea/{data,indexers,log}
mkdir /etc/gitea
chown root:git /etc/gitea
chmod 770 /etc/gitea
wget https://raw.githubusercontent.com/go-gitea/gitea/master/contrib/systemd/gitea.service
nano gitea.service
Now in nano, you need to add the After=postgresql.service line, once that's done, hit CTRL+S to save, and CTRL+X to exit.
cp gitea.service /etc/systemd/system/
systemctl enable gitea
Next we'll setup postgresql:
apt-get -y install apt-transport-https lsb-release ca-certificates curl gnupg -y
sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
apt update -y
apt install postgresql-13 -y
su -c "psql" - postgres
CREATE ROLE gitea WITH LOGIN PASSWORD 'gitea';
CREATE DATABASE giteadb WITH OWNER gitea TEMPLATE template0 ENCODING UTF8 LC_COLLATE 'en_US.UTF-8' LC_CTYPE 'en_US.UTF-8';
exit
Next we'll configure Nginx:
apt install nginx -y
Here we're going to use DuckDNS because it is a free way to get a domain name, but if you have your own paid domain name, you can use it too.
Once that's done, we will setup acme.sh to get a free letsencrypt certificate:
apt install socat -y
wget -O - https://get.acme.sh | sh
source ~/.bashrc
systemctl stop nginx
acme.sh --issue --standalone -d ech2.duckdns.org -k 4096
systemctl start nginx
Once this is done, download the nginx configuration for gitea:
wget https://ech1.github.io/blog/servers/Gitea/gitea.conf -O /etc/nginx/sites-enabled/gitea.conf
nano /etc/nginx/sites-enabled/gitea.conf
Once you're done editing your domain name inside the config, hit CTRL+S to save, and CTRL+X to exit nano and reload nginx:
nginx -t
nginx -s reload
apt install git
systemctl start postgresql gitea
Once that's done simply browse to your website and set it up after clicking the "register button":
Here in this example i intend to use gitea for my own use, but if you want to have multiple users here, you can untick "disable self registration", If it is for only one user, tick it and create the administrator user at the bottom of the page:
Once that's done, hit "install gitea" and then we go back into the ssh root shell to change the directories permissions:
chmod 750 /etc/gitea
chmod 644 /etc/gitea/app.ini
And there you have it!
Just like in github, click the "+" at the top right corner:
From here you can clone the repository on your local machine:
[ 192.168.100.1/24 ] [ /dev/pts/10 ] [~/Documents/Github]
→ git clone https://ech2.duckdns.org/nothing/mycoolrepo
Use the administrator's gitea credentials to clone the repository if you set it to private, and you're done! You can now start editing your self-hosted repository.
To customise the default gitea theme do the following:
echo '[ui]' >> /etc/gitea/app.ini
echo 'THEMES = gitea,arc-green,lain' >> /etc/gitea/app.ini
echo 'DEFAULT_THEME = lain' >> /etc/gitea/app.ini
cd /var/lib/gitea/custom
git clone https://github.com/ech1/gitea-lain-template .
chown git:git /var/lib/gitea/{data,indexers,log}
chmod 750 /var/lib/gitea/{data,indexers,log}
chown root:git /etc/gitea
chmod 770 /etc/gitea
chmod 750 /etc/gitea
chmod 644 /etc/gitea/app.ini
systemctl restart postgresql gitea
Some Address 67120,
Duttlenheim, France.
This cute theme was created to showcase your work in a simple way. Use it wisely.