Tuesday, January 4, 2022

How to Install Gitea with PostgreSQL Apache HTTP 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.
Apache is the most widely used web server software.
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 apache2
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
http://localhost:3000/

a2enmod ssl proxy proxy_ajp proxy_wstunnel proxy_http rewrite deflate headers proxy_balancer proxy_connect proxy_html
systemctl restart apache2
nano /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:*>
    ProxyPreserveHost On

    # Servers to proxy the connection, or;
    # List of application servers:
    # Usage:
    # ProxyPass / http://[IP Addr.]:[port]/
    # ProxyPassReverse / http://[IP Addr.]:[port]/
    # Example:
    ProxyPass / http://localhost:3000/
    ProxyPassReverse / http://localhost:3000/

    ServerName debian.example.com
</VirtualHost>

apache2ctl configtest
systemctl restart apache2 ; systemctl status apache2
echo "192.168.1.60  debian.example.com debian" >> /etc/hosts
_________________________________________________________________________________________________________________________









No comments:

Post a Comment