GitBucket as a service on Debian 1

If you want to host your own Git Server you have multiple possibilities. Here I want to describe how to run GitBucket, an Open Source GitHub like platform.

The focus of this article is to show you how to setup GitBucket as a service (incl. autostart) on a Debian OS.

Installation in short

Java 8

GitBucket required Java8 to run. So first we install Java8 on the machine if not already done.

This will add additional repositories to your system that contains the Java8 installer (not the Java8 binaries). This installer will download Java8 binaries for you and install them correctly. While installing you have to accept the license and after that you can check the java version with the following command:

For more detailed description see HOW TO INSTALL ORACLE JAVA 8 IN DEBIAN VIA REPOSITORY [JDK8].

User and GitBucket


First of all  we should avoid to run services using root user because of security reasons. So we will create a new user, switch to that user and go to the home directory:

After that we download the latest version of GitBucket from GitHub Releases:

Now you can first run GitBucket using the following command:

See GitBucket readme for detailed information.

Run as a service with autostart on boot

Now we want to setup GitBucket as a service with autostart on OS boot.

For that we create two files with the following contents:

File: :

Copy that file to the home directory of the user “gitbucket”  /home/gitbucket and execute the following commands:

This file contains the logic to start/stop/restart/status commands for GitBucket service.


File: gitbucket :

Copy this file to  /etc/init.d  and execute the following commands:

This file defines the gitbucket service that can be automatically started.

Now you have to start the service by your own (if you don’t want to restart the complete server):


Gitbucket access on port 80

Here we want to use Gitbucket on port 80 parallel to Apache Webserver using  mod_proxy .

Install and enable mod_proxy  and mod_proxy_http :

Add new VirtualHost configuration (ignore .well-known  requests for Let’s Encrypt):

Restart Apache

Disable direct access for GitBucket, it should be only accessable over the Proxy. Edit the and change the commandline parameters:




Leave a comment

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

One thought on “GitBucket as a service on Debian

  • Andrej Chvalov

    Debian 8

    oot@ns535971:/etc/init.d# nano /etc/init.d/gitbucket
    root@ns535971:/etc/init.d# chmod 755 /etc/init.d/gitbucket
    root@ns535971:/etc/init.d# update-rc.d gitbucket default
    usage: update-rc.d [-n] [-f] remove
    update-rc.d [-n] disable|enable [S|2|3|4|5]
    -n: not really
    -f: force

    The disable|enable API is not stable and might change in the future.