What
Gogs is a painless self-hosted Git service
Why
There are many distributed version-control systems (DVCS) available as a SaaS service provided by many vendors, famous are GitHub, GitLab, Bitbucket, Mercurial etc. But if you want to maintain an own private DVCS, then you can do this with Gogs.
How
All OS Installation Package available at https://packager.io/gh/gogs/gogs
Gogs Installation on CentOS 7
- OS Updates and hostname setup
- yum -y update
- hostnamectl set-hostname git.company.com
- Make sure SeLinux disabled
Database Installation
- yum -y install wget
- vi /etc/yum.repo.d/mariadb.repo
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.4/rhel7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=0 - yum –enablerepo=mariadb install mariadb-server -y
- systemctl enable –now mariadb
- mysql_secure_installation (set password)
MariaDB [(none)]>
CREATE DATABASE gogs DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER ‘gogsuser’ IDENTIFIED BY ‘PASSWORD’;
GRANT ALL privileges ON gogs.* TO ‘gogsuser’@’localhost’ IDENTIFIED BY ‘PASSWORD’ WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;
Gogs Installation
- yum install -y git
- wget -O /etc/yum.repos.d/gogs.repo https://dl.packager.io/srv/gogs/gogs/master/installer/el/7.repo
- yum install gogs
- systemctl enable –now gogs
Web Setup
- yum -y install epel-release
- yum -y install nginx
- vi /etc/nginx/conf.d/gogs.conf (Change domain name and certificates)
server {
listen 80;
server_name gogs.company.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443;
server_name gogs.company.com;
keepalive_timeout 70;
ssl on;
ssl_certificate /etc/ssl/certs/company.com.crt;
ssl_certificate_key /etc/ssl/private/company.com.key;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/gogs.access.log;
error_log /var/log/nginx/gogs.error.log error;
location / {
proxy_pass http://localhost:6000/;
proxy_set_header Host $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;
proxy_redirect http://localhost:6000 https://$server_name;
proxy_read_timeout 90;
}
}
systemctl enable –now nginx
Access the site https://gogs.company.com and do the initial configuration