From ArchWiki
Jump to: navigation, search

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: Configuration of SMTP, oAuth, logging, caching (Discuss in Talk:Gogs#)

Gogs (Go Git Service) is a Self Hosted Git service, which was written in the Go programming language.


Each package provides multiple options for configuring the backend/storage for the service, see #Configuration


Installing Gogs from the AUR instead of manually has the added benefit that lots of steps have been taken care of for you (e.g. permissions and ownership for files, etc).

Also before installing the Gogs package from the AUR, you need to choose a database backend if you're planning to host Gogs on the same machine as the database:

If you plan to use SSH to interact with your repositories, make sure to add the gogs user to the AllowUsers entry in /etc/ssh/sshd_config.

First start

After starting gogs.service, you can access the running service over the url http://[server]:3000. At first load, you will be redirected to the installation page where you can configure some options. In order to be able to save changes made using the initial configuration page the permissions of the configuration file (owned by root) will have to be modified (either temporary or permanently), for example:

# chown gogs:gogs /etc/gogs/app.ini

In the configuration file /etc/gogs/app.ini, you can change more values (for example the port number).


The Gogs configuration file is located at /etc/gogs/app.ini. When you want to edit a configuration option, you need to edit this file and restart the Gogs service before changes will take effect.


In order to interact with the git repositories using ssh, and to be able to use the uploaded public keys:

  • set SSH_ROOT_PATH in /etc/gogs/app.ini to /var/lib/gogs/.ssh (see also documentation), and ensure that DISABLE_SSH is false.
  • Add gogs to AllowUsers in /etc/ssh/sshd_config.
  • create /var/lib/gogs/.ssh and hand over ownership to the gogs user:
> mkdir -p /var/lib/gogs/.ssh
> chown -R gogs:gogs /var/lib/gogs/.ssh

Public keys will be added by the gogs user to /var/lib/gogs/.ssh/authorized_keys

.gitignore and license files

A set of gitignore and license files are included in the package and are stored at /usr/share/gogs/conf/gitignore and /usr/share/gogs/conf/license respectively.

You can get or create your own .gitignore files here.



Install sqlite and select SQLite on the installation page. Use an absolute path in /etc/gogs/app.ini (PATH variable in the [database] section) for the SQLite database file. To be consistent with the other settings, use /var/lib/gogs/data/gogs.db (see also issue 4298).


Install postgresql and select Postgresql on the installation page.

# su - postgres -c 
# createuser -P gogs
# createdb -O gogs gogs


Install mariadb and setup a user and database:

# CREATE DATABASE `ishouldchangethisdatabasename` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
# CREATE USER 'ishouldchangethisusername'@'localhost' IDENTIFIED BY 'ishouldchangethispassword';
# GRANT ALL ON `ishouldchangethisdatabasename`.* TO 'ishouldchangethisusername'@'localhost';

On the installation page select mysql and insert your configured user, password and database name.


The current package (gogs-git* and gogs>=0.4.2) support custom themes. The location for Gogs themes is /usr/share/themes/gogs/. Gogs comes with one default theme, but you can easily create a own theme. Just copy the default theme directory and change whatever you want. In the public directory is every javascript, stylesheet and font file and in the template directory are the HTML templates. The current selected theme can be changed over the app.ini configuration parameter STATIC_ROOT_PATH. Changed it with the absolute path to the new theme.

Restart after Upgrade

Gogs needs to be restarted after every upgrade because the paths of javascript/css assets will change and therefore break the website. To automate this the following pacman hook can be inserted at /etc/pacman.d/hooks/gogs.hook:

Type = File
Operation = Upgrade
Target = usr/share/gogs/gogs
Description = Restart gogs...
When = PostTransaction
Exec = /usr/bin/systemctl try-restart gogs.service

SSH port

If you are using a non-default port for your SSH server, you will get not-so-pretty clone URLs. You can make gogs start its own SSH server, listening on port 22.

Allow gogs binary to bind privileged ports:

# setcap CAP_NET_BIND_SERVICE=+eip /usr/share/gogs/gogs

Configure gogs SSH server in /etc/gogs/app.ini:

START_SSH_SERVER       = true
SSH_PORT               = 22
SSH_LISTEN_PORT        = 22

See also