How to install Gogs on CentOS 7

To install Gogs on CentOS 7

Gogs is a free, open source, and easy-to-use self-hosted Git service, and it is similar to GitLab. It is written using the Go language, hence it supports all platforms such as Linux, Windows, OS X and ARM. Installing Gogs is very simple and in this tutorial, you will be briefed about the method to install Gogs on CentOS 7. 

Pre- requirements
Install LAMP
In MariaDB (create database, user and privileges to user)
PHP > 5.6


Installing Gogs

Get into the html location by running the following command.

 [root@linuxhelp ~]# cd /var/www/html/

From there, you can download the gogs packages with the help of wget command. 

[root@linuxhelp html]#  wget
--2017-11-11 16:06:06--
Resolving (
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 19075459 (18M) [application/zip]
Saving to: ‘’

100%[======================================>] 1,90,75,459  589KB/s   in 39s    

2017-11-11 16:06:47 (480 KB/s) - ‘’ saved [19075459/19075459]


Once the file is downloaded, you can extract the downloaded file.

[root@linuxhelp html]# unzip 
   creating: gogs/
   creating: gogs/public/
   creating: gogs/public/plugins/
   creating: gogs/public/plugins/highlight-9.6.0/
  inflating: gogs/public/plugins/highlight-9.6.0/github.css  
  inflating: gogs/public/plugins/highlight-9.6.0/highlight.pack.js  
  inflating: gogs/public/plugins/highlight-9.6.0/default.css  
   creating: gogs/public/plugins/jquery.datetimepicker-2.4.5/
  inflating: gogs/public/plugins/jquery.datetimepicker-2.4.5/jquery.datetimepicker.js  
inflating: gogs/scripts/init/centos/gogs  
   creating: gogs/scripts/init/freebsd/
  inflating: gogs/scripts/init/freebsd/gogs  
  inflating: gogs/scripts/mysql.sql  
  inflating: gogs/gogs               


After that, you need to change the ownership of gogs directory as follows.

[root@linuxhelp html]# chown -R apache.apache gogs/

Once it is done, you can create a .conf file for configuring the VirtualHost

[root@linuxhelp html]# vim /etc/httpd/conf.d/gogs.conf


Once the file is opened, add the following lines.

<VirtualHost *:80>
DocumentRoot /var/www/html/gogs/
<Directory /var/www/html/gogs/>
Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
ErrorLog /var/log/httpd/
CustomLog /var/log/httpd/ common



Later, you need to make an entry in the in hosts file as follows.  

root@linuxhelpubnt:/var/www/html# nano /etc/hosts
<<machine ip> domainname(give in virtualhost)

Now, enter into the gogs directory

[root@linuxhelp html]# cd gogs/


And then execute the gogs. 

[root@linuxhelp gogs]# ./gogs web &
[1] 6398
2017/11/11 16:13:06 [TRACE] Custom path: /var/www/html/gogs/custom
2017/11/11 16:13:06 [TRACE] Log path: /var/www/html/gogs/log
2017/11/11 16:13:06 [TRACE] Log Mode: Console (Trace)
2017/11/11 16:13:06 [ INFO] Gogs
2017/11/11 16:13:06 [ INFO] Cache Service Enabled
2017/11/11 16:13:06 [ INFO] Session Service Enabled
2017/11/11 16:13:06 [ INFO] SQLite3 Supported
2017/11/11 16:13:06 [ INFO] Run Mode: Development
2017/11/11 16:13:06 [ INFO] Listen:

Once it is done, restart the Apache service. 

[root@linuxhelp gogs]# systemctl restart httpd

Open your browser and give as the URL, the installation page of gogs appears on your screen. 

Fill all the needed details and click the install gogs option. 



The login page gets opened. Click on Need an account? Sign up now option to open a new account in Gogs. 

Fill the needed details and click Create.

Enter your newly created credentials and click on Sign in option

The home page of Gogs now appears on your screen. 
You can go to the Admin Panel to make some modification in your account.
With this, the installation of Gogs comes to an end. 

Thank you! for using Linux Help.

You find this tutorial helpful? Share with your friends to keep it alive.
For more help topics browse our website
Be the first to comment, we value your suggestions. For further queries please comment below.

Tags: CentOS Git
user image Author :  Jayce