How to Install Gitblit on Debian Latest
Introduction
Gitblit is an open-source, pure Java Git server designed for use with Git repositories. It provides a web interface and supports multiple protocols for accessing the repositories. Gitblit is easy to install and run and offers numerous features, including access control, code reviews, and more.
In this tutorial, we will show you how to install Gitblit on Debian 10 (Buster) using the official Gitblit package.
Prerequisites
Before you begin, you should have administrative access to a Debian 10 (Buster) system.
Step 1: Update the System
Before installing Gitblit, it is always recommended to update your system to the latest packages.
sudo apt update
sudo apt upgrade
Step 2: Install Java
Gitblit requires a Java Runtime Environment (JRE) to run. We'll install the OpenJDK 11 package from the official Debian repositories.
sudo apt install openjdk-11-jre-headless
Step 3: Download Gitblit Package
Head over to the official Gitblit website and download the latest Gitblit package from the download page.
wget https://github.com/gitblit/gitblit/releases/download/vX.XX.X/gitblit-X.XX.X.tar.gz
Replace X.XX.X with the version number of the Gitblit package you downloaded.
Step 4: Extract the Gitblit Package
Now that the Gitblit package is downloaded, extract it to a directory of your choice. For example, we'll extract it to /opt.
sudo tar -xzf gitblit-X.XX.X.tar.gz -C /opt/
Step 5: Create a User
Gitblit should not run as the root user, so we'll create a new user for it to run as.
sudo useradd -r -d /var/gitblit -s /bin/false gitblit
This command creates a new system user named gitblit with a home directory of /var/gitblit and no login shell.
Step 6: Configure Gitblit
Gitblit is now installed and ready to be configured. The default configuration file is located at /opt/gitblit/data/gitblit.properties. You can customize the settings in this file to meet your needs.
For example, you may want to change the Gitblit server listening port from the default port 8080 to a different port. To do so, edit the server.httpPort property in the gitblit.properties file.
nano /opt/gitblit/data/gitblit.properties
Update the server.httpPort property to the desired port number.
server.httpPort = 9000
Save the file and exit.
Step 7: Start Gitblit
You can start Gitblit as the gitblit user using the following command:
sudo -u gitblit /opt/gitblit/gitblit.sh start
This command will start the Gitblit server in the background as the gitblit user. You can access the Gitblit web interface by opening your web browser and navigating to http://your-server-ip:port/.
Replace your-server-ip with the IP address of your Debian system and port with the HTTP port number you configured in the gitblit.properties file.
Conclusion
In this tutorial, you learned how to install Gitblit on Debian 10 (Buster) using the official Gitblit package. You also learned how to configure the Gitblit server and start it as a non-root user.