Skip to content

Instantly share code, notes, and snippets.

@gangsta
Created November 15, 2017 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gangsta/435cb3a6dd610f03b8176bb12b6a79c1 to your computer and use it in GitHub Desktop.
Save gangsta/435cb3a6dd610f03b8176bb12b6a79c1 to your computer and use it in GitHub Desktop.
How To Install Gogs

How To Install Gogs

First of all ,be sure that you have created user “gogs” .

sudo su - #installing gogs useradd gogs passwd gogs

After that we need to prepare database section to have local database for gogs . In our case its PostgreSql.

RHEL/CentOS 5/6:

yum install postgresql-server postgresql chkconfig postgresql on service postgresql start

RHEL/CentOS 7:

yum install postgresql-server postgresql postgresql-setup initdb systemctl enable postgresql systemctl start postgresql

Set up a PostgreSQL database for Gogs:

cd /tmp sudo -u postgres psql -c "CREATE ROLE gogs WITH LOGIN PASSWORD 'gogs'" sudo -u postgres createdb -O gogs -E UTF8 gogs sudo -u postgres createlang plpgsql gogs

Locate your pg_hba.conf (Debian: /etc/postgresql/*/main/pg_hba.conf, RHEL/SUSE: /var/lib/pgsql/data/pg_hba.conf), add the gogs user with md5 authentication method and restart the postgresql server.

vi /var/lib/pgsql/data/pg_hba.conf

gogs

local gogs gogs md5 host gogs gogs 127.0.0.1/32 md5 host gogs gogs ::1/128 md5

“local” is for Unix domain socket connections only

local all all ident

IPv4 local connections:

host all all 127.0.0.1/32 ident

IPv6 local connections:

host all all ::1/128 ident

Restart service PostgreSql

service postgresql restart

Installation of gogs using RPM package:

Surf to : https://packager.io/gh/pkgr/gogs

Choose latest version of Centos6 or CentOS7 RPM package

or

yum localinstall https://pkgr-production-rpm.s3.amazonaws.com/gh/pkgr/gogs/centos7/pkgr/gogs-0.9.13-1458763757.5ec8ef0.centos7.x86_64.rpm?AWSAccessKeyId=AKIAJFGZVGZONQB4NGVA&Expires=1462966977&Signature=af5SQRZRlzosbiFCSdwsgPCCg0Y%3D

In case if you want to use Repo Do:

sudo rpm --import https://rpm.packager.io/key echo "[gogs] name=Repository for pkgr/gogs application. baseurl=https://rpm.packager.io/gh/pkgr/gogs/centos7/pkgr enabled=1" | sudo tee /etc/yum.repos.d/gogs.repo sudo yum install gogs -y

After installation please run : sudo rm /etc/systemd/system/gogs* -rf

to be sure that there is no systemd script .

Now lets install systemd Script . vi /lib/systemd/system/gogs.service

with context:

[Unit] Description=Gogs (Go Git Service) After=network.target #After=mysqld.service After=postgresql.service

[Service] LimitMEMLOCK=infinity LimitNOFILE=165535 User=gogs WorkingDirectory=/opt/gogs ExecStart=/opt/gogs/gogs web Restart=always Environment=USER=gogs HOME=/home/gogs/

[Install] WantedBy=multi-user.target

Start Gogs service :

systemctl daemon-reload

service gogs start

now lets configure gogs :

mkdir -p /opt/gogs/custom/conf/

vi /opt/gogs/custom/conf/app.ini

copy this context:

APP_NAME = MyCompany: Go Git Service RUN_USER = gogs RUN_MODE = prod

[database] DB_TYPE = postgres HOST = 127.0.0.1:5432 NAME = gogs USER = gogs PASSWD = gogs SSL_MODE = disable PATH = data/gogs.db

[repository] ROOT = /home/gogs/gogs-repositories

[server] DOMAIN = 10.0.1.10 HTTP_PORT = 3000 ROOT_URL = http://10.0.1.10:3000/ DISABLE_SSH = false SSH_PORT = 22 OFFLINE_MODE = false

[mailer] ENABLED = true

[service] REGISTER_EMAIL_CONFIRM = false ENABLE_NOTIFY_MAIL = true DISABLE_REGISTRATION = true ENABLE_CAPTCHA = true REQUIRE_SIGNIN_VIEW = true ENABLE_REVERSE_PROXY_AUTHENTICATION = true ENABLE_REVERSE_PROXY_AUTO_REGISTERATION = true

[picture] DISABLE_GRAVATAR = false

[session] PROVIDER = file

[log] MODE = file LEVEL = debug ROOT_PATH = /opt/gogs/log

[security] INSTALL_LOCK = true SECRET_KEY = 1pPg7bn13TSc0kn

[mailer] ENABLED = true

[service] REGISTER_EMAIL_CONFIRM = false ENABLE_NOTIFY_MAIL = true DISABLE_REGISTRATION = true ENABLE_CAPTCHA = true REQUIRE_SIGNIN_VIEW = true ENABLE_REVERSE_PROXY_AUTHENTICATION = true ENABLE_REVERSE_PROXY_AUTO_REGISTERATION = true

[picture] DISABLE_GRAVATAR = false

[session] PROVIDER = file

[log] MODE = file LEVEL = debug ROOT_PATH = /opt/gogs/log

[security] INSTALL_LOCK = true SECRET_KEY = 1pPg7bn13TSc0kn

Restart Gogs service using : service gogs restart

Be sure that you have PORT:3000 open.

systemctl start firewalld.service

firewall-cmd --add-port=3000/tcp --zone=public --permanent

firewall-cmd --reload

Surf to localhost:3000 and get gogs interface

In next post I`ll show you how to configurate AUTH with AD or with Freeipa (LDAP)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment