Skip to content

Instantly share code, notes, and snippets.

@diyfr
Last active May 24, 2017 11:52
Show Gist options
  • Save diyfr/d6b8b9c137a9176b742928ef3513956a to your computer and use it in GitHub Desktop.
Save diyfr/d6b8b9c137a9176b742928ef3513956a to your computer and use it in GitHub Desktop.
Install an private web-based Git repository manager on ubuntu 16.04 : Gogs

Install Git

sudo apt-get install git

Install Gogs binary

Get package from gogs (https://gogs.io/docs/installation/install_from_packages)[https://gogs.io/docs/installation/install_from_packages]
and decompress-it
Be carefull with roles (don't use root account and prefer an user account or specifically an new user like 'git')
move into gogs folder and start

./gogs web

Default start on port 3000 use -port .... for specify another port

You can't install gogs behind reverse proxy, because installation screen start from root

Apache configuration in reverse proxy

Activate the proxy module for apache

a2enmod proxy

and add in virtualhost (here subdirectory used is /gogs )

    ProxyPass /gogs http://127.0.0.1:3000 retry=0 KeepAlive=On
    ProxyPassReverse /gogs http://127.0.0.1:3000

don't miss to reload apache

Account and Disable free registration

The first created user is an admin user.
Edit {GOGS_FOLDER}/custom/app/app.ini
In [SERVICE] section change value of DISABLE_REGISTRATION (Disable registration, after which only admin can create accounts for users)
to true

Daemonize simply gogs

Install Supervisor (http://supervisord.org/)[http://supervisord.org/]

sudo apt-get install supervisor

Create a directory for the log files

sudo mkdir -p /var/log/gogs

Add a Supervisor configuration file for gogs

sudo nano /etc/supervisor/conf.d/gogs.conf

paste this( update if necessary here user is named 'git' )

[program:gogs]
directory=/home/git/gogs/
command=/home/git/gogs/gogs web
autostart=true
autorestart=true
startsecs=10
stdout_logfile=/var/log/gogs/stdout.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=10
stdout_capture_maxbytes=1MB
stderr_logfile=/var/log/gogs/stderr.log
stderr_logfile_maxbytes=1MB
stderr_logfile_backups=10
stderr_capture_maxbytes=1MB
environment = HOME="/home/git", USER="git"
user = git

Restart Supervisor

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