gogs@Debian12.md 4.5 KB

apt -y update
apt -y install git

Developer has no official own repo, packager.io will be used in order to maintain updates.

wget -qO- https://dl.packager.io/srv/gogs/gogs/key | sudo apt-key add -
wget -O /etc/apt/sources.list.d/gogs.list \
    https://dl.packager.io/srv/gogs/gogs/main/installer/debian/12.repo
apt update
apt -y install gogs
ss -ntap | grep 6000
LISTEN    0      4096               *:6000                *:*     users:(("gogs",pid=69825,fd=3))

Database install, secure and configure

apt install mariadb-server
mysql_secure_installation
mysql -u root -p
CREATE DATABASE IF NOT EXISTS gogs;
CREATE USER 'gogs'@'localhost' IDENTIFIED BY 'pass';
GRANT ALL PRIVILEGES ON gogs.* TO 'gogs'@'localhost';
FLUSH PRIVILEGES;

Webserver (Nginx) installation and configuration

apt install -y nginx
vi /etc/nginx/sites-available/gogs.2dz.fi.conf
# TODO: review
server {
    listen         6000;
    server_name    gogs.2dz.fi;
    location / {
        proxy_pass http://localhost:6000;
    }
}

# Redirection HTTP>HTTPS and Certbot parts will be added later.

Enable config, test and restart

ln -s /etc/nginx/sites-available/gogs.2dz.fi.conf /etc/nginx/sites-enabled/
nginx -t
systemctl restart nginx

Navigate to http://host/install using WebBrowser connect to DB using gogs's user

To reset admin's password:

sudo su
systemctl stop gogs-web-1
su - gogs
cd /opt/gogs/
./gogs admin create-user --name tmpuser --password tmppassword --admin --email email@example.com --config /etc/gogs/conf/app.ini
exit
systemctl start gogs-web-1

Login as tmpuser:tmppassword, Top-Right icon, Admin Panel, Users, do changes, logout-login, remove temp user.

Make config backup and configure:

cd /etc/gogs/conf
cp app.ini app.ini.2024-02-25--1743

edit configuration file

vi app.ini
BRAND_NAME = gogs.2dz.fi
RUN_USER   = gogs
RUN_MODE   = prod

[database]
TYPE     = mysql
HOST     = localhost:3306
NAME     = gogs
SCHEMA   = public
USER     = gogs
PASSWORD = superpass
SSL_MODE = disable
PATH     = /opt/gogs/data/gogs.db

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

[server]
DOMAIN           = gogs.2dz.fi
HTTP_PORT        = 443
EXTERNAL_URL     = https://gogs.2dz.fi/
DISABLE_SSH      = false
SSH_PORT         = 22maybe22
START_SSH_SERVER = true
OFFLINE_MODE     = false

# not [mailer], but
[email]
ENABLED = true
# HOST    = external-service:2525
# USER    = external-auth-user
# PASSWD  = external-auth-pass
SUBJECT = [gogs.2dz.fi]
HOST    = 127.0.0.1:25
SKIP_VERIFY = true
FROM    = gogs@2dz.fi
USE_PLAIN_TEXT = true
ENABLE_HTML_ALTERNATIVE = false

# not [service], but
[auth]
REQUIRE_EMAIL_CONFIRMATION  = true
DISABLE_REGISTRATION        = false
ENABLE_REGISTRATION_CAPTCHA = true
REQUIRE_SIGNIN_VIEW         = false
REGISTER_EMAIL_CONFIRM      = true
SHOW_REGISTRATION_BUTTON    = true
ENABLE_CACHE_AVATAR         = false
ENABLE_NOTIFY_MAIL          = true
ENABLE_CAPTCHA              = true

[user]
ENABLE_EMAIL_NOTIFICATION = true

[picture]
DISABLE_GRAVATAR        = true
ENABLE_FEDERATED_AVATAR = false

[session]
PROVIDER = file

[log]
MODE      = file
# LEVEL     = Trace
LEVEL = Info
ROOT_PATH = /opt/gogs/log

[security]
INSTALL_LOCK = true
SECRET_KEY   = this-is-random

Enable registration captcha and email confirmation

restart gogs with

systemctl restart gogs

because of

systemctl | grep  gogs
gogs-web-1.service        loaded active running   gogs-web-1.service
gogs-web.service          loaded active running   gogs-web.service
gogs.service              loaded active running   gogs.service

after looking into

/opt/gogs# fgrep -irn mailer .

turns out, that:

[...]
./CHANGELOG.md:50:-  Configuration section `[mailer]` is no longer used, please use `[email]`.
./CHANGELOG.md:190:- Configuration section `[mailer]` is deprecated and will end support in 0.13.0, please start using `[email]`.

begin to understand, that configuration's variables' names are outdated

looking into CHANGELOG.md

- Configuration section `[mailer]`  is no longer used, please use `[email]`.
- Configuration section `[service]` is no longer used, please use `[auth]`.

opened pull request

https://github.com/gogs/docs/pull/268

Known issues:

Can not start gogs-web-1. Log directory is not writable for gogs user.

chown -R gogs:gogs /opt/gogs/log/

Ref:

https://gogs.io/docs/installation
https://gogs.io/docs/installation/install_from_packages