Gogs – Opensource alternative to Github

gogs logoGithub is probably the most popular git repository hosting platform. But unfortunately Github itself is not open source and cannot be installed on your own server. This is where Gogs enter.

 

Gogs, for Go Git Service, is an opensource self hosted git repository hosting platform under MIT license. Written in Go, Gogs, is easy to install (Either with docker or with binaries), lightweight (minimal requirements).

Through a web interface, it allows you to share, manage and control the revision of your source code with different access rights for different people and several collaborative features (bug tracker,…).

Gogs is also multi-platforms (Can run on Windows, MacOS and Linux type of systems). They accept MySQL, PostgreSQL and SQLite as database and can run on Apache or Nginx. Quite flexible then.

You can directly try their demo version or follow the below installation steps to run your own instance of gogs on your server.

 

Installation

Gogs offers various binary packages for Debian, Ubuntu, CentOS and even Arch. So the installation will be straightforward.

 

1) Add their repository to your source.list

As they use HTTPS connections to their repository, you will need to install apt-transport-https.

In root (or with sudo in front), run:

apt-get install apt-transport-https

Then add their repository with the following commands:

wget -qO - https://deb.packager.io/key | apt-key add -
echo "deb https://deb.packager.io/gh/pkgr/gogs wheezy pkgr" | tee /etc/apt/sources.list.d/gogs.list
apt-get update

 

2) Install Gogs
apt-get install gogs

It will install the latest available version and start the service automatically. Gogs will run behind the port 6000 but will need to be accessible with the port 80 (or 443 if you prefer).

 

3) Create a dedicated virtualhost

If you simply try to access http://yourIP:6000, your web-browser will block the connection. My Iceweasel (Firefox) is saying:

“This address uses a network port which is normally used for purposes other than Web browsing. Iceweasel has canceled the request for your protection”. This is because I must create a proxypass from the port 6000 to 80, in order to let my web-browner render the service.

You will first need to install the mod-proxy-html

apt-get install libapache2-mod-proxy-html

while you will also need to activate the mod-proxy-http (Already installed)

a2enmod proxy_http

Then you can configure your virtualhost. Make sure to create a A or CNAME redirection in your DNS registrar.

Here is a simple virtualhost you can reuse:

Still in root:

nano /etc/apache2/sites-enabled/gogs

and copy paste:

<VirtualHost *:80>
        ServerAdmin webmaster@domain.tld
        ServerName gogs.domain.tld

        ProxyRequests Off
        <Proxy *>
        Order deny,allow
        Allow from all
        </Proxy>
        ProxyPass / http://localhost:6000/
        ProxyPassReverse / http://localhost:6000/
</VirtualHost>

Simply restart your apache service

/etc/init.d/apache2 restart

and you’re good to browse http://gogs.domain.tld to access to the web installer.

 

4) Web-installer

You should now have access to Gogs’web installer.

gogs installation mysql

– You will need to set up a database (Either MySQL, PostgreSQL or SQLite). In my case, I’m using MySQL and I’ve created a dedicated database/user/password through PHPMyAdmin.

– You will also need to set-up a local directory for your git projects, gogs user (default one should work) and application URL (The one you are using right now)

gogs installation general settings

– SMTP settings (Optional)

– Admin account

When done, you should be able to use Gogs right away along with all your favorite git commands.

gogs log in

Gravatar

Loves to discover web-based apps to install on his own server@home and write articles about it

0 Comments:

Add a comment