A guide to install gitea on Debian 11#
Here is a quick guide to Install Gitea with Postgresql on Debian 11
Start with a quick system update:
sudo apt-get update -ysudo apt-get upgrade -ySetup postgresql#
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
# Import repo signing key with:wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get updatesudo apt-get -y install postgresqlSystem setup#
sudo systemctl start postgresqlsudo systemctl enable postgresqlsudo systemctl status postgresqlNext, You need to switch to ’SCRAM-SHA-256’ scheme from md5 encryption scheme for better security. If you want to connect to PostgreSQL remotely, then you need to allow your IP address in the PostgreSQL configuration file. Open Configuration file to make changes using the following command:
sudo vim /etc/postgresql/15/main/postgresql.conf
# Inside file uncomment:
listen_addresses = 'localhost, 45.32.225.46'password_encryption = scram-sha-256Then, restart systemd service:
sudo systemctl restart postgresqlLogin in to postgresql#
sudo -u postgres psqlInside psql:
postgres=# CREATE ROLE gitea WITH LOGIN PASSWORD 'secure@123';
postgres=# CREATE DATABASE giteadb;
postgres=# GRANT ALL PRIVILEGES ON DATABASE giteadb TO gitea;
postgres=# exitif you receive the error:
The database settings are invalid: migrate: sync: pq: permission denied for schema publicyou might have to do the following in psql after the install is complete, I did:
ALTER DATABASE gitea OWNER TO giteaWithin /etc/postgresql/15/main/pghba.conf file:#
host giteadb gitea 134.122.38.0/32 scram-sha-256Install and configure git:#
sudo apt install gitgit --version
git config --global user.name "Your Name"git config --global user.email "youremail@domain.com”git config --listCreate git user for gitea#
sudo adduser \ --system \ --shell /bin/bash \ --gecos 'Git Version Control' \ --group \ --disabled-password \ --home /home/git \ gitInstall gitea:#
wget https://dl.gitea.com/gitea/1.20.3/gitea-1.20.3-linux-amd64 -O /usr/local/bin/giteasudo chmod +x /usr/local/bin/giteaMake directory structure for gitea:
sudo mkdir -p /etc/gitea
sudo mkdir -p /var/lib/gitea/{custom,data,indexers,public,log}
sudo chown -R git:git /var/lib/gitea/
sudo chown root:git /etc/gitea
sudo chmod -R 750 /var/lib/gitea/
sudo chmod 770 /etc/giteaCreate systemd service file:
sudo vim /etc/systemd/system/gitea.serviceInside:
[Unit]Description=GiteaAfter=syslog.targetAfter=network.targetAfter=postgresql.service
[Service]RestartSec=2sType=simpleUser=gitGroup=gitWorkingDirectory=/var/lib/gitea/ExecStart=/usr/local/bin/gitea web -c /etc/gitea/app.iniRestart=alwaysEnvironment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea
[Install]WantedBy=multi-user.target
sudo systemctl daemon-reloadsudo systemctl start giteasudo systemctl enable giteasudo systemctl status gitea
# Verify running on port 3000:netstat -tulpan | grep 3000Navitate to port 3000 on your server and you will see it running!
Congrats, you have now dropped github as your git server.