Saturday, February 15, 2020

How To Install Gitea Git Service With Nginx on Ubuntu 18.04

Video Tutorial -   https://youtu.be/HiHDa2gCFTA
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Gitea is an alternative open source, self-hosted version control system powered by git. Gitea is written in Golang and is a lightweight solution to be hosted on any platform.
𝐎𝐟𝐟𝐜𝐢𝐚𝐥 𝐖𝐞𝐛𝐬𝐢𝐭𝐞:https://gitea.io/en-us/
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
𝐎𝐮𝐫 𝐒𝐞𝐫𝐯𝐞𝐫 𝐒𝐩𝐞𝐜𝐢𝐟𝐢𝐜𝐚𝐭𝐢𝐨𝐧- 𝐎𝐬:𝐔𝐛𝐮𝐧𝐭𝐮 𝟏𝟖.𝟎𝟒 𝐋𝐓𝐒 𝐁𝐢𝐨𝐧𝐢𝐜 𝐁𝐞𝐚𝐯𝐞𝐫 𝟔𝟒𝐁𝐢𝐭 | 𝐇𝐨𝐬𝐭𝐧𝐚𝐦𝐞 :𝐰𝐰𝐰.𝐲𝐨𝐮𝐫𝐝𝐨𝐦𝐚𝐢𝐧.𝐜𝐨𝐦   |𝐈𝐏 𝐚𝐝𝐝𝐫𝐞𝐬𝐬- 𝟏𝟗𝟐.𝟏𝟔𝟖.𝟏.𝟓𝟎   
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
lsb_release -cd ; hostname ; hostname -I ; whoami ; getconf LONG_BIT ; apt install -y build-essential software-properties-common net-tools git make wget curl lsb-release

apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8 ; add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://mirror.biznetgio.com/mariadb/repo/10.4/ubuntu bionic main'

apt-get update ; apt install -y nginx mariadb-server mariadb-client
systemctl start nginx mariadb ; systemctl enable nginx mariadb ; mysql_secure_installation
mysql -u root -p
create database db;
grant all on db.* to 'dbuser'@'localhost' identified by 'dbpass';
flush privileges;
quit

wget https://github.com/go-gitea/gitea/releases/download/v1.5.1/gitea-1.5.1-linux-amd64
cp gitea-1.5.1-linux-amd64 /usr/local/bin/gitea
chmod 755 /usr/local/bin/gitea
adduser --system --shell /bin/bash --group  --disabled-password --home /home/gitea gitea
mkdir -p /etc/gitea /var/lib/gitea/{custom,data,indexers,public,log}
chown gitea:gitea /etc/gitea /var/lib/gitea/{custom,data,indexers,public,log}
chmod 750 /var/lib/gitea/{data,indexers,log}
chmod 770 /etc/gitea
nano /etc/systemd/system/gitea.service
[Unit]
Description=Gitea
After=syslog.target
After=network.target
After=mysql.service

[Service]
RestartSec=2s
Type=simple
User=root
Group=root
WorkingDirectory=/var/lib/gitea/
ExecStart=/usr/local/bin/gitea web -c /etc/gitea/app.ini
Restart=always
Environment=USER=root HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea

[Install]
WantedBy=multi-user.target
systemctl start gitea ; systemctl status gitea ; systemctl enable gitea


rm /etc/nginx/sites-enabled/default
nano /etc/nginx/sites-available/gitea
upstream gitea {
    server 127.0.0.1:3000;
}

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name www.yourdomain.com;
    root /var/lib/gitea/public;
    access_log off;
    error_log off;

    location / {
      try_files maintain.html $uri $uri/index.html @node;
    }

    location @node {
      client_max_body_size 0;
      proxy_pass http://localhost:3000;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header Host $http_host;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_max_temp_file_size 0;
      proxy_redirect off;
      proxy_read_timeout 120;
    }
}

ln -s /etc/nginx/sites-available/gitea /etc/nginx/sites-enabled/
nginx -t  ; echo "192.168.1.50 www.yourdomain.com" >> /etc/hosts ; systemctl restart nginx
http://www.yourdomain.com/install. Y

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

No comments:

Post a Comment