Skip to content

Instantly share code, notes, and snippets.

@AndreaGhizzoni
Last active April 25, 2018 10:05
Show Gist options
  • Save AndreaGhizzoni/b08e0d8acb892e95366385662f38b06c to your computer and use it in GitHub Desktop.
Save AndreaGhizzoni/b08e0d8acb892e95366385662f38b06c to your computer and use it in GitHub Desktop.
gogs-server.md

Create a new user

$ useradd -m -d /home/git -s /bin/bash git
$ sudo passwd git
$ su - git
$ whoami
git
$ pwd
/home/git
$ sudo apt-get install -y postgresql postgresql-client libpq-dev git ssh unzip
$ sudo -u postgres psql -d template1

Then within psql prompt, enter:

# Create a user for git
# The following are typed in postgresql prompt
CREATE USER git CREATEDB;

# Set up a password for git
# Remember this password for the next step
\password git

# Create the Gogs database & grant all privileges on database
CREATE DATABASE gogs_production OWNER git;

# Quit the database session
\q

# Try connecting to the new database with the new user
$ sudo -u git -H psql -d gogs_production

# Quit the database session
gogs_production> \q

Getting Gogs

Choose the version and

$ wget https://dl.gogs.io/0.11.43/gogs_0.11.43_linux_amd64.zip
$ unzip gogs_0.11.43_linux_386.zip
$ cd gogs
$ pwd
/home/git/gogs

Enabling Gogs as a service

All scripts you need are under gogs/scripts.

$ cd /etc/init.d
$ sudo cp /home/git/gogs/scripts/init/debian/gogs .

Modify it as you need, then

$ cd /etc/systemd/system
$ sudo cp /home/git/gogs/scripts/systemd/gogs.service

Then modify it to set which database you are using. At this point just:

$ sudo su -
$ service gogs start
$ systemctl enable gogs.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment