Tuesday, January 4, 2022

How to Install Gitea with PostgreSQL Nginx web server on Debian 11

 Gitea is a community managed lightweight code hosting solution written in Go. || PostgreSQL is an advanced, enterprise-class, and open-source relational database system.
Offcial Website : https://gitea.io/en-us/
________________________________________________________________________________________________________________________
๐Ž๐ฎ๐ซ ๐’๐ž๐ซ๐ฏ๐ž๐ซ ๐’๐ฉ๐ž๐œ๐ข๐Ÿ๐ข๐œ๐š๐ญ๐ข๐จ๐ง:-
๐Ž๐ฌ : ๐ƒ๐ž๐›๐ข๐š๐ง ๐Ÿ๐Ÿ ๐›๐ฎ๐ฅ๐ฅ๐ฌ๐ž๐ฒ๐ž ๐Ÿ”๐Ÿ’ ๐๐ข๐ญ     || ๐‡๐จ๐ฌ๐ญ๐ง๐š๐ฆ๐ž:  debian.example.com     || ๐ˆ๐ ๐€๐๐๐ซ๐ž๐ฌ๐ฌ ๐จ๐Ÿ ๐’๐ž๐ซ๐ฏ๐ž๐ซ:192.168.1.60
________________________________________________________________________________________________________________________
                            lsb_release -cd  ; getconf LONG_BIT ; hostname ; hostname -I
 
apt install -y build-essential net-tools curl git software-properties-common nginx
sudo 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 | sudo apt-key add -
apt-get update ; sudo apt-get -y install postgresql -y
systemctl start postgresql ; systemctl enable postgresql ; systemctl status postgresql

nano  /etc/postgresql/14/main/postgresql.conf
listen_addresses = 'localhost, 0.0.0.0'
password_encryption = scram-sha-256
systemctl restart postgresql

sudo -u postgres psql
CREATE ROLE gitea WITH LOGIN PASSWORD 'secure@123';
CREATE DATABASE giteadb;
GRANT ALL PRIVILEGES ON DATABASE giteadb TO gitea;
exit

git config --global user.name "Your Name"
git config --global user.email "youremail@yourdomain.com"

sudo adduser \
   --system \
   --shell /bin/bash \
   --gecos 'Git Version Control' \
   --group \
   --disabled-password \
   --home /home/git \
   git

cd /tmp ; GITEAVERSION=1.15.7
wget -O gitea https://dl.gitea.io/gitea/${GITEAVERSION}/gitea-${GITEAVERSION}-linux-amd64
mv /tmp/gitea /usr/local/bin ; chmod +x /usr/local/bin/gitea
mkdir -p /etc/gitea ; mkdir -p /var/lib/gitea/{custom,data,indexers,public,log} ; chown -R git:git /var/lib/gitea/ ; chown root:git /etc/gitea ; chmod -R 750 /var/lib/gitea/ ;chmod 770 /etc/gitea


nano /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
systemctl daemon-reload ; systemctl start gitea ; systemctl enable gitea ; systemctl status gitea

nano /etc/nginx/sites-enabled/default
server {

listen 80;
index index.php index.html index.htm;

server_name debian.example.com;
                
location / {
proxy_pass http://localhost:3000;
proxy_set_header Host $http_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;
}
}

nginx -t
systemctl restart nginx ; systemctl status nginx
http://debian.example.com
_________________________________________________________________________________________________________________________

No comments:

Post a Comment