1. Home
  2. Linux
  3. Ubuntu
  4. Install Gogs on Ubuntu 16.04

Install Gogs on Ubuntu 16.04

Install Gogs on Ubuntu 16.04
Install Gogs on Ubuntu 16.04

In this guide we will show you how to install Gogs on Ubuntu 16.04. Gogs is a free and open source self-hosted Git service, made in the Go programming language, it’s similar to GitLab and it’s goal is to be the simplest and most painless way to have a self-hosted Git service in your development environment. IT’s installation is kind of fast and easy.

Requirements

Gogs has a couple of requirements that you will need to install so that Gogs runs on your Ubuntu server.

  • SSH server
  • Database server:
    – MySQL: Version 5.5.3 or newer
    – PostgreSQL
    – MSSQL
    – TiDB
    – SQLite3
  • Git version 1.7.1 or newer

Updating the System

Begin by logging into your Ubuntu 16.04 server via SSH as user root:

ssh root@IP_Address

Ensure that every system package is up-to-date by executing the command below:

apt-get update && apt-get upgrade

Install the MYSQL server and then create the database:
Execute the command below so the MySQL server is installed on your server.

apt-get install mysql-server

After it’s installed, we will execute the mysql_secure_installation script so the MySQL is secured, and then we will set a password for the root user.

mysql_secure_installation
Remove anonymous users? (Press y|Y for Yes, any other key for No) :
Disallow root login remotely? (Press y|Y for Yes, any other key for No) :
Remove test database and access to it? (Press y|Y for Yes, any other key for No) :
Reload privilege tables now? (Press y|Y for Yes, any other key for No) :

Once we’ve done that, we may login to the MySQL server as root and create a database for Gogs:

CREATE DATABASE gogs;
GRANT ALL PRIVILEGES ON gogs.* TO 'gogs'@'localhost' IDENTIFIED BY 'YOUR_PASSWORD';
FLUSH PRIVILEGES;
\q

Install and Configure Gogs

Create a new system user which will run Gogs

useradd --system --create-home git

Switch the user

Su git
cd ~

Download the latest Gogs version which matches your system (32 bit or 64 bit)

wget https://dl.gogs.io/0.11.29/linux_amd64.zip

Now unpack the downloaded zip archive

apt-get install unzip
unzip linux_amd64.zip

Execute the command below to initiate Gogs:

cd gogs && ./gogs web &

By default Gogs will be running on port 3000. So, open your web browser of choice and point it to http://IP_Address:3000 . Gogs  is going to automatically detect that this is the first time its running and redirect to the setup screen.
With the information below, you may configure Gogs:
Database Settings:

  • Database Type: MySQL
  • Host: 127.0.0.1:3306
  • User: gogs
  • Password: YOUR_PASSWORD
  • Database Name: gogs

Application General Settings:

  • Application Name: Gogs
  • Repository Root Path: /home/git/gogs-repositories
  • Run User: git
  • Domain: domain.com
  • SSH Port: 22 // use your SSH port number
  • HTTP Port: 3000
  • Application URL: http://domain.com

Next, we will click the ‘install Gogs’ button so the installation is complete, and if everything is configured correctly, you should be directed to the Gogs login screen where you may create your first account and begin using this useful application. Once you’ve signed in, you should be able to create, clone, push, repositories and use Gogs for your needs.

Updated on December 23, 2018

Was this article helpful?

Related Articles

Leave a Comment

[apsl-login-lite login_text='Please login with a social account']