$ 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
$ 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
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