visit
Here is a quick guide on how to Install Gitea with Postgresql on Debian 11
sudo apt-get update -y
sudo apt-get upgrade -y
sudo sh -c 'echo "deb //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 - //www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install postgresql
sudo systemctl start postgresql
sudo systemctl enable postgresql
sudo systemctl status postgresql
sudo vim /etc/postgresql/15/main/postgresql.conf
# Inside file uncomment:
listen_addresses = 'localhost, 45.32.225.46'
password_encryption = scram-sha-256
sudo systemctl restart postgresql
sudo -u postgres psql
postgres=# CREATE ROLE gitea WITH LOGIN PASSWORD 'secure@123';
postgres=# CREATE DATABASE giteadb;
postgres=# GRANT ALL PRIVILEGES ON DATABASE giteadb TO gitea;
postgres=# exit
The database settings are invalid: migrate: sync: pq: permission denied for schema public
you might have to do the following in psql after the install is complete, I did:
ALTER DATABASE gitea OWNER TO gitea
Within /etc/postgresql/15/main/pghba.conf file:
host giteadb gitea 134.122.38.0/32 scram-sha-256
sudo apt install git
git --version
git config --global user.name "Your Name"
git config --global user.email "[email protected]”
git config --list
sudo adduser \
--system \
--shell /bin/bash \
--gecos 'Git Version Control' \
--group \
--disabled-password \
--home /home/git \
git
wget //dl.gitea.com/gitea/1.20.3/gitea-1.20.3-linux-amd64 -O /usr/local/bin/gitea
sudo chmod +x /usr/local/bin/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/gitea
sudo vim /etc/systemd/system/gitea.service
[Unit]
Description=Gitea
After=syslog.target
After=network.target
After=postgresql.service
[Service]
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
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl start gitea
sudo systemctl enable gitea
sudo systemctl status gitea
# Verify running on port 3000:
netstat -tulpan | grep 3000
Navigate to port 3000 on your server and you will see it running!