Here is a quick guide on how to Install Gitea with on Debian 11 Postgresql Start with a quick system update: sudo apt-get update -y sudo apt-get upgrade -y Setup 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 update sudo apt-get -y install postgresql System setup sudo systemctl start postgresql sudo systemctl enable postgresql sudo systemctl status postgresql Next, 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 the 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-256 Then, restart the systemd service: sudo systemctl restart postgresql Login into postgresql sudo -u postgres psql Inside 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 if you receive the error: 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 Install and configure git: sudo apt install git git --version git config --global user.name "Your Name" git config --global user.email "youremail@domain.com” git config --list Create git user for gitea sudo adduser \ --system \ --shell /bin/bash \ --gecos 'Git Version Control' \ --group \ --disabled-password \ --home /home/git \ git Install gitea: wget https://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 Make 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/gitea Create systemd service file: sudo vim /etc/systemd/system/gitea.service Inside: [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! Congrats, you have now dropped GitHub as your Git server. Also published here.