Install-Gogs-on-Ubuntu-16-04-1

Install Gogs on Ubuntu 16.04

Spread the love

We’ll explain to you, How to install Gogs on Ubuntu 16.04. Gogs is a free and open source self-hosted Git service, written in the Go programming language. It is very similar to GitLab and aims to be the easiest and most painless way to set up self-hosted Git service in your development environment. Its installation is pretty fast and simple

In this tutorial, we will learn how to install Gogs with Apache as a reverse proxy on Ubuntu 16.04 server.

Prerequisites

Gogs has several prerequisites that you have to install in order to run Gogs 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

Update the system

Login to your Ubuntu 16.04 server via SSH as user root:

ssh root@IP_Address

Make sure that all your system packages are up-to-date:

apt-get update && apt-get upgrade

Install MySQL server and create database

run the following command to install MySQL server on your server.

apt-get install mysql-server

Once installed, execute the mysql_secure_installation script to secure the MySQL server and set 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) :

After that, login to the MySQL server as user 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 that will run Gogs

useradd --system --create-home git

Switch the user

su git
cd ~

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

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

Unpack the downloaded zip archive

apt-get install unzip
unzip linux_amd64.zip

Run the following command to start Gogs

cd gogs && ./gogs web &

Gogs by default is running on port 3000. So, open your favorite web browser and navigate it to http://IP_Address:3000 . Gogs will automatically detect that this is the first run and redirect to the setup screen.

Use the following information to 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

And click the ‘Install Gogs’ button to complete the installation. If everything is properly configured, you will be redirected to Gogs login screen where you can create your first account and start using this useful application. After signing in, you will be able to create, clone, push, repositories and use Gogs for your needs.

For more information on how to use Gogs and its features, please check their official documentation.


Of course you don’t have to do any of this if you use one of our Linux Host Support Services, in which case you can simply ask our expert Linux admins to setup this for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Leave a Reply

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