About Gogs

  • There are multiple services, which allows hosting Git repositories online.
  • Out of these services Gogs is a lightweight and self-hosted solution.
  • Online repository hosting using Gogs is very easy.
  • Gogs are written in ‘Go’ and it requires much less hardware compared to Gitlab.
  • It provides easiest, fastest and most painless way of setting up a self-hosted Git service.
  • If a user is familiar with GitHub, then it is easy to understand Gogs.
  • Gogs support all platform like Linux, Windows, macOS etc

Installation

  • Before installation user will need to set up a system. To install Gogs, a user should install Git, SSH server and a database such as MySQL or PostgreSQL.
  • In this guide, we will be installing MySQL and Git on CentOS.
  • Run command to update system
#yum -y update

 

  • Setup hostname for a server, it will be easy to identify.
#hostnamectl set-hostname gogs.devopstech.com

 

MySQL and GIT installation and configuration

  • The following command will add MySQL repository on server

#wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm

#rpm -ivh mysql57-community-release-el7-8.noarch.rpm

#yum -y update

 

  • Install MySQL using the following command

#yum install mysql-server git (On CentOS machine)

#apt-get install mysql-server git (On Ubuntu machine)

 

  • Add a Gogs user and set home directory for Gogs user
#useradd -d /opt/gogs gogs

 

Configuring the Database

  • If a user on Ubuntu, the database server will be auto-started at the time of installation.
  • However, with CentOS/RHEL, you will need to start it up manually. You will also have to “enable” it so that MySQL starts up whenever your system boots up.
  • To do so, run the following command

#sudo systemctl start mysqld (On CentOS machine)

#sudo systemctl enable mysqld (On CentOS machine)

#sudo systemctl start mysql (On Ubuntu machine)

 

  • During installation, the root user of MySQL is assigned a random password in CentOS. To get that password run the following command
#grep ‘temporary password’ /var/log/mysqld.log

 

  • Run the following command to secure MySQL installation
#mysql_secure_installation

(User will be asked for your MySQL root password. Enter your temporary password. Once logged in, change the password for root user. You will be prompted with few more questions. Recommended is that you answer ‘y’ for all questions.)

 

  • Now try to login to the MySQL console as a root user
#mysql -u root -p

 

  • Create user in MySQL
#CREATE USER gogs@localhost IDENTIFIED BY ‘password’;

 

  • Create a database ‘gogs’ and allow new user to work on that database

#CREATE DATABASE gogs;

#GRANT ALL PRIVILEGES ON gogs.* TO gogs@localhost;

(Note down database name, user and password – user will need them.)

Install and configure Gogs

  • There are two ways to install Gogs:
    • Install from Binary.
    • Install from Source.

 

  • Extract the downloaded archive
sudo tar -xf linux_amd64.tar.gz -C /opt/gogs/

 

  • Now go to extracted directory and execute the following command

cd gogs

./gogs web

 

  • User can start Gogs using following command
  • For on-boot start service use enable command

#systemctl start gogs

#systemctl enable gogs

 

  • Now go to http://localhost:3000, it will open installation page, In that user have to provide the mandatory details and login.

Figure: Gogs UI configuration

Conclusion

Hence Gogs is proven to be the easiest way to handle git repositories for user projects. It is an open source project which has active community support. With Gogs, a user can perform any tasks which can be done via git. So go ahead and try it out.

 

 

Reference

– https://www.booleanworld.com/install-gogs-github-style-git-remote-service/

– https://gogs.io/docs/installation

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


CAPTCHA Image
Reload Image