Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
114 lines (78 sloc) 2.88 KB
From source

Install from source



We are going to create a new user called git and install/setup everything under that user:

$ sudo adduser --disabled-login --gecos 'Gogs' git

Installing Go

If your system's Go matches the requirements, please skip this section.


Install Go in /home/git/local/go so it wouldn't interfere with future updates of your system's package manager:

$ sudo su - git
$ cd ~
# create a folder to install 'go'
$ mkdir local
# Download go (change go$VERSION.$OS-$ARCH.tar.gz to the latest release)
$ wget$VERSION.$OS-$ARCH.tar.gz
# expand it to ~/local
$ tar -C /home/git/local -xzf go$VERSION.$OS-$ARCH.tar.gz

Set Up the Environment

Set the paths that correspond to your system:

$ sudo su - git
$ cd ~
$ echo 'export GOROOT=$HOME/local/go' >> $HOME/.bashrc
$ echo 'export GOPATH=$HOME/go' >> $HOME/.bashrc
$ echo 'export PATH=$PATH:$GOROOT/bin:$GOPATH/bin' >> $HOME/.bashrc
$ source $HOME/.bashrc

Install Gogs

The general way to install Gogs:

# Download and install dependencies
$ go get -u

# Build main program
$ cd $GOPATH/src/
$ go build

Build from develop branch

In case you want to try develop (or any other) branch:

$ mkdir -p $GOPATH/src/
$ cd $GOPATH/src/

# Make sure you don't use ""
$ git clone --depth=1 -b develop
$ cd gogs
$ go build

Test Installation

To make sure Gogs is working:

$ cd $GOPATH/src/
$ ./gogs web

If you do not see any error messages, hit Ctrl-C to stop Gogs.

Build with Tags

A couple of things do not come with Gogs automatically, you need to compile Gogs with corresponding build tags.

Available build tags are:

  • sqlite: SQLite3 database support
  • pam: PAM authentication support
  • cert: Generate self-signed certificates support
  • miniwinsvc: Builtin windows service support (or you can use NSSM to create a service)

For example, you want to support all of them, first delete directory $GOPATH/pkg/${GOOS}_${GOARCH}/ and then do:

$ go get -u -tags "sqlite pam cert"
$ cd $GOPATH/src/
$ go build -tags "sqlite pam cert"

If you get error: fatal error: security/pam_appl.h: No such file or directory, then install missing package via sudo apt-get install libpam0g-dev.

Next steps