How To Install Gogs On Ubuntu 16.04

1. SSH into the server

$ ssh user@ip_address

2. Create the Gogs database

(a) login to mysql:

$ mysql -u root -p

(b) create the database:

mysql> CREATE DATABASE gogs CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;


mysql> \q

3. Download the binary file for Gogs available at

the file link I am using as of March 9, 2017 is version 0.10.8:

to download this archive to the server:

$ wget

4. Unpack the archive:

$ tar -xvf linux_amd64.tar.gz

5. Change into gogs directory:

$ cd gogs

6. Run Gogs

$ ./gogs web

Now Gogs is running. To access, open a browser and type in the ip address of the server with port 3000, for example:


This should take you to the Installation screen where you can enter the required information:

  1. You can change the database type to something other than MySQL if you wish.
  2. Enter database username and password
  3. Change the ‘Application Name' to anything you wish
  4. Enter ‘Run User' name as the same name that you used to install Gogs
  5. Change ‘Domain' if you like (for example, or leave as is.
  6. Change ‘Application Url' to the same domain that you chose above (if you changed it)

Optionally, you can open the ‘Admin Account Settings' tab under ‘Optional Settings' and create an Admin account now. Otherwise, whoever's ID=1 will gain admin access automatically.

To stop the Gogs process/server enter “Ctrl-c” on the command line. When you do this, Gogs will no longer be running at the ip address.

To run Gogs continuously in the background, even when we exit git:

$ ./gogs web &

note that we just added an ‘&' (ampersand) to the end of the command.

Now if we type ‘exit' on the command line to exit the git console, Gogs still runs in the background.

$ exit

To stop Gogs from running in the background:

$ killall gogs

additional note: when we first run the command to allow Gogs to run in the background, if we press ‘enter' or any other keys the default command line displays. However, once we refresh the Gogs page or do anything else in Gogs, the command line will switch to view the activities. To avoid this, I had to logout of the git console (‘exit') and log back in. After doing this, Gogs activities were no longer reflected in the console (although Gogs still runs in the background until you ‘killall gogs').


Need a solution to use self-certified encryption with LetsEncrypt (SSL). I believe it has something to do with the config file in ‘/gogs/custom/conf/app.ini' discussed here: but I need more testing. I already have self-certified keys that work with other apps on the server and need to find a way to use these same keys to work for Gogs, if possible.


This link seems to be a viable solution but I have yet to attempt it yet. Seems very simple.

You have to build Gogs with build tags cert (official binaries are included this tag by default).

After that, execute the following command is all you need:

$ ./gogs cert -ca=true -duration=8760h0m0s

Don't forget to replace with your own domain.

OK, now you should have two new files in the current directory: cert.pem and key.pem.

Config HTTPS Certificates

If you're using reverse proxy, all you need to do on Gogs's configuration is making sure your ROOT_URL is using a HTTPS URL, such as, and NOTHING ELSE!

For NGINX, see example below:

server {  
    listen 443 ssl;
    ssl_certificate path/to/cert.pem;
    ssl_certificate_key path/to/key.pem;

    location / {
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_pass http://localhost:3000$request_uri;

# Redirect HTTP requests to HTTPS
server {  
    listen 80;
    return 301 https://$host$request_uri;

That's it. But there are comments on the linked page that report errors when doing this so…

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.