Install Gogs on Ubuntu 16.04

0
423

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.

I. 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

II. Updating the System

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

apt-get update && apt-get upgrade
Every system package is up-to-date
Every system package is up-to-date

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
Install the MYSQL server
Install the MYSQL server
Configuring mysql-server-5.7 Step 1
Configuring mysql-server-5.7 Step 1
Configuring mysql-server-5.7 Step 2
Configuring mysql-server-5.7 Step 2

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
mysql_secure_installation Step 1
mysql_secure_installation Step 1
mysql_secure_installation Step 2
mysql_secure_installation Step 2

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

To log in to MySQL as the root user:

mysql -u root -p
CREATE DATABASE gogs;
GRANT ALL PRIVILEGES ON gogs.* TO 'gogs'@'localhost' IDENTIFIED BY 'YOUR_PASSWORD';
FLUSH PRIVILEGES;
\q
Login to the MySQL server as root and create a database for Gogs
Login to the MySQL server as root and create a database for Gogs

III. Install and Configure Gogs

Create a new system user which will run Gogs

useradd --system --create-home git
sudo apt-get install unzip

Switch the user

Su git
cd ~
Create a new system user which will run Gogs
Create a new system user which will run Gogs

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
Download the latest Gogs version
Download the latest Gogs version

Now unpack the downloaded zip archive

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.

If you have any questions or feedback, feel free to comment below.

LEAVE A REPLY

Please enter your comment!
Please enter your name here