1. Initialize User

As root, add the user git:

adduser git

Set the password:

passwd git

Initialize a login shell to the user:

su git -

2. Download

Move to the home directory:

cd

Download the binary package from:

wget https://cdn.gogs.io/0.11.43/gogs_0.11.43_linux_amd64.tar.gz

Untar and unzip:

tar zxf gogs_0.11.43_linux_amd64.tar.gz

3. Congifure

Move into the directory:

cd ./gogs

Start the web config:

 ./gogs web
# # 2018/05/10 15:31:45 [ WARN] Custom config '/home/git/gogs/custom/conf/app.ini' not found, ignore this if you're running first time
# # 2018/05/10 15:31:45 [TRACE] Custom path: /home/git/gogs/custom
# # 2018/05/10 15:31:45 [TRACE] Log path: /home/git/gogs/log
# # 2018/05/10 15:31:45 [TRACE] Log Mode: Console (Trace)
# # 2018/05/10 15:31:45 [ INFO] Gogs 0.11.43.0330
# # 2018/05/10 15:31:45 [ INFO] Cache Service Enabled
# # 2018/05/10 15:31:45 [ INFO] Session Service Enabled
# # 2018/05/10 15:31:45 [ INFO] SQLite3 Supported
# # 2018/05/10 15:31:45 [ INFO] Run Mode: Development
# # 2018/05/10 15:31:45 [ INFO] Listen: http://0.0.0.0:3000

Since we’ll be using it, make sure you see: [ Info] SQLite3 Supported in the output. Note the path of the custom config file, in this case: /home/git/gogs/custom/conf/app.ini. Open a Chrome browser and navigate to <hostname>:3000.

Here is a sample configuration, note I’m making sure all the directories specified will be owned by the git user:

Click Install, you should be automatically logged in and brought to your dashboard:

Running as a Service

Go back to the console you submitted the ./gogs web command from, you should see some network traffic logged, e.g.:

# 2018/05/10 16:35:22 [ INFO] Gogs 0.11.43.0330
# [Macaron] 2018-05-10 16:35:23: Completed POST /install 302 Found in 10.656515735s
# [Macaron] 2018-# # 05-10 16:35:23: Started GET /user/login for [::1]
# [Macaron] 2018-05-10 16:35:23: Completed GET /user/login 302 Found in 1.407201ms
# [Macaron] 2018-05-10 16:35:23: Started GET / for [::1]
# [Macaron] 2018-05-10 16:35:23: Completed GET / 200 OK in 12.458642ms

Kill the process. Save a copy of the service script:

cp /gogs/scripts/systemd/gogs.service /gogs/scripts/systemd/gogs.service.bkp 

Then open the script and verify that the following fields are pointing to the correct files – edit (and save) if necessary:

User=git
Group=git
WorkingDirectory=/home/git/gogs
ExecStart=/home/git/gogs/gogs web
Restart=always
Environment=USER=git HOME=/home/git

Get back into a root login shell and copy the file to the user service file directory:

cp /home/git/gogs/scripts/systemd/gogs.service /etc/systemd/system/
chmod 664 /home/git/gogs/scripts/systemd/gogs.service

NOTE: by physically copying the file there we are replacing the systemctl enable step which would have symlinked our original file to that location

Restart the systemd daemon and start the service:

systemctl daemon-reload
systemctl start gogs.service

Check the status, it now should be running:

systemctl status gogs.service# 
# ● gogs.service - Gogs
#    Loaded: loaded (/etc/systemd/system/gogs.service; enabled; vendor preset: disabled)
#    Active: active (running) since Thu 2018-05-10 17:05:41 CDT; 3min 35s ago
#  Main PID: 8356 (gogs)
#     Tasks: 10
#    Memory: 47.6M
#    CGroup: /system.slice/gogs.service
#            └─8356 /home/git/gogs/gogs web
# 
# May 10 17:05:41 IMPERATORIS2 systemd[1]: Started Gogs.
# May 10 17:05:41 IMPERATORIS2 systemd[1]: Starting Gogs...
# May 10 17:05:41 IMPERATORIS2 gogs[8356]: 2018/05/10 17:05:41 [TRACE] Custom path: /home/git/gogs/custom
# May 10 17:05:42 IMPERATORIS2 gogs[8356]: 2018/05/10 17:05:41 [TRACE] Log path: /home/git/gogs/log
# May 10 17:05:42 IMPERATORIS2 gogs[8356]: 2018/05/10 17:05:41 [TRACE] Log Mode: File (Trace)
# May 10 17:05:42 IMPERATORIS2 gogs[8356]: 2018/05/10 17:05:41 [ INFO] Gogs 0.11.43.0330

Open your browser again and navigate to <hostname>:3000, you should see the welcome splash:

Congratulations! You’re now hosting.

Reference page.