For Some strange reason I felt the need to set up my own git server - because who doesn’t need an own server for the two or three projects you keep on github? I looked around and searched for some solutions that would fit my needs.">
For Some strange reason I felt the need to set up my own git server - because who doesn’t need an own server for the two or three projects you keep on github? I looked around and searched for some solutions that would fit my needs."/>
For Some strange reason I felt the need to set up my own git server - because who doesn’t need an own server for the two or three projects you keep on github? I looked around and searched for some solutions that would fit my needs." />
<p>For Some strange reason I felt the need to set up my own git server - because who doesn’t need an own server for the two or three projects you keep on github?
I looked around and searched for some solutions that would fit my needs.</p>
<p>My requirements were:</p>
<ul>
<li>Easy setup</li>
<li>Very Low System requirements for the host</li>
<li>Account management</li>
<li>Private and Public Repos</li>
<li>Open Source</li>
</ul>
<h2id="the-possibilities">
The Possibilities
<aclass="heading-link"href="#the-possibilities">
<iclass="fa fa-link"aria-hidden="true"></i>
</a>
</h2>
<p>There were multiple solutions to choose from.</p>
<p>The first one was <ahref="https://about.gitlab.com/install/">GitLab Core</a>. <ahref="https://about.gitlab.com">GitLab</a> is widely know and a nice alternative to <ahref="https://github.com/">GitHub</a>. But GitLab core does require some more System resources then my current Server has and so I ruled it out. It is good for bigger companies but I just needed something small.</p>
<p><ahref="https://gitea.io/en-us/">Gitea</a> was the next thing I came across. It checks all the boxes: lightweight, simple install, Open Source, etc. I downloaded it but had trouble getting it to run with my current database without exposing my database port to the internet and that is a big No. I don’t want to open any more ports in my firewall then I need to.</p>
<p>Here is where <ahref="https://gitbucket.github.io/">GitBucket</a> (not to be confused with ATLASSIANs <ahref="https://bitbucket.org/">Bitbucket</a>) came into play. It has similar features as Gitea but I was able to set it up exactly how I wanted to.</p>
<p>So now <ahref="https://git.n0x.io/">git.n0x.io</a> is a thing!</p>
<p>Just FYI I am running a little Debian 9 vServer so you might need to adapt the commands and changes to your system - which should be self-explanatory ;)</p>
<p>GitBucket is mostly written in Scala so we firstly need to install openJDK on our Server to run it.</p>
<pre><code>sudo apt update
sudo apt install openjdk-11-jre
</code></pre>
<p>After installing the JRE I created a user account on which GitBucket should run. This way we make sure that I we do not grant to much privileges to GitBucket - it only gets the minimal things it needs to run</p>
<pre><code>sudo adduser --system gitbucket
</code></pre>
<p>The <code>--system</code> parameter creates a systemuser account which mean a user that has no shell so we can’t log into it the normal <code>su</code> way. To login to the new user use the following command:</p>
<pre><code>sudo su - gitbucket -s /bin/bash
</code></pre>
<p>With <code>-s /bin/bash</code> we provide a shell to the user so we don’t get logged out immediately.</p>
<p>Now we download the <ahref="https://github.com/gitbucket/gitbucket/releases/">latest version</a> of BitBucket (in my case 4.32.0) from GitHub to our local home.</p>
<p>That is pretty much it. Now we can run GitBucket.war for the first time. There are multiple parameters you can specify (<ahref="https://github.com/gitbucket/gitbucket#installation">See the official installation guide</a>) but for now we stick with just specifying the port we want GitBucket to run on initially</p>
<pre><code>java -jar gitbucket.war --port=8080
</code></pre>
<p>If you have a firewall set up like I do, you of course need to open up the port you specified. For example if you use iptables:</p>