How To Install GitBucket with Nginx on Ubuntu 18.04 LTS

Install GitBucket with Nginx on Ubuntu 18.04 LTS

GitBucket is a free and open-source for yor using Git platform powered by Scala with Github API compatibility. It is simple, lightweight and alternative to Github and BitBucket. It comes with reach set of features including, support for GitLFS, issues, pull request, notifications, plug-in system, Public and Private Git repositories.

It can be easily integrated with LDAP for a accounts and your groups management. In this tutorial, we will learn how to installing and using configure GitBucket on Ubuntu 18.04 server.

Compatibility

  • A fresh server with Ubuntu ver.18.04.
  • A root for the password is configured on your instances.

Let’s starting

Before starting, please update your system with the latest stable version. You can do it with the following command:

apt-get update -y
apt-get upgrade -y

Once updated, restart your server to apply all the configuration changes.

Please Install Java

GitBucket requires Java 8 and newer to be installing on your server. So, you will need to always install Java on your server.

To install Java run the following command:

apt-get install default-jdk -y

Once your the Java is installing, you can do check the versions latest of Java using the following command:

java -version

You should see the following output:

openjdk version “10.0.2” 2018-07-17
OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.2)
OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.2, mixed mode)

Once you have finishing, you can do proceed to the next step process.

Installing the GitBucket

Before installing the GitBucket, you will need to creating an unprivileged users admin to run GitBucket.

Run the following command to create a system user’s called gitbucket.

groupadd -g 555 gitbucket
useradd -g gitbucket –no-user-group –home-dir /opt/gitbucket –no-create-home –shell
/usr/sbin/nologin –system –uid 555 gitbucket

Next

Please downloaded the GitBucket from the Git repository with the following command:

wget https://github.com/gitbucket/gitbucket/releases/download/4.31.2/gitbucket.war

Once the downloaded is completed, creating a directory for GitBucket inside /opt

mkdir /opt/gitbucket

Next

  • Move the download files in gitbucket directory:

mv gitbucket.war /opt/gitbucket

Next

  • Give proper permission to the gitbucket directory with the following is a command:

chown -R gitbucket:gitbucket /opt/gitbucket

Once you have finishing, you can do proceed to the next step.

And your success

The next step
do the following activities

Create Systemd Service files for GitBucket

you will need to create a Systemd services the files for GitBucket to manage GitBucket services. You can do create it with the following command:

nano /etc/systemd/system/gitbucket.service

And you can also add

# GitBucket Service
[Unit]
Description=Manage Java service

[Service]
WorkingDirectory=/opt/gitbucket
ExecStart=/usr/bin/java -Xms128m -Xmx256m -jar gitbucket.war
User=gitbucket
Group=gitbucket
Type=simple
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target

After you add the code above, don’t forget to

Save and close the files.
Then, reload the System with the following command:

systemctl daemon-reload

Next

start gitbucket service and please enable it to starting working on boot times with the following command:

systemctl enable gitbucket
systemctl start gitbucket

You can now checking the status of gitbucket with the following command:

systemctl status gitbucket

After you do the following, make sure you are still in front of your computer. And you should see the following output:

? gitbucket.service – Manage Java service
Loaded: loaded (/etc/systemd/system/gitbucket.service; disabled; vendor preset: enabled)
Active: active (running) since Tue 2019-08-09 09:43:42 UTC; 5s ago
Main PID: 17835 (java)
Tasks: 18 (limit: 1113)
CGroup: /system.slice/gitbucket.service
??17835 /usr/bin/java -Xms128m -Xmx256m -jar gitbucket.war

Aug 09 09:43:42 ubuntu1804 systemd[1]: Started Manage Java service.
Aug 09 09:43:45 ubuntu1804 java[17835]: 2019-07-09 09:43:45.102:INFO::main: Logging initialized @2700ms to org.eclipse.jetty.util.log.StdErrLog
Aug 09 09:43:46 ubuntu1804 java[17835]: 2019-07-09 09:43:46.134:INFO:oejs.Server:main: jetty-9.4.z-SNAPSHOT; built: 2018-11-14T21:20:31.478Z; g
lines 1-11/11 (END)

This step is complete and successful. you can proceed to the next step.

Configure Database Connections for GitBucket

GitBucket coming with an embedded H2 database. To configure the database connection open database.conf files with your favourite text editor:

nano /opt/gitbucket/database.conf

Add the following lines:

db {
url = “jdbc:h2:${DatabaseHome};MVCC=true”
user = “sa”
password = “sa”
}

This step is complete and successful. you can proceed to the next step.

Configure Nginx as a Reverse Proxy

By default, GitBucket runs on port 8080. And you will need to configurating Nginx as a reverse the proxy to improve performances working and enabling other features like, HTTP/2 and TLS encryption.

To do so, first installing Nginx with the following command:

apt-get install nginx -y

Next

Create a reverse proxy for GitBucket by creating the following files:

Add the following lines

upstream gitbucket {
server 127.0.0.1:8080 weight=100 max_fails=5 fail_timeout=5;
}

server {
listen 80;
server_name your-domain.com;

location / {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://gitbucket/;
   }
}

Save and close the files.

And Then, enable Nginx virtual host use the following command:

ln -s /etc/nginx/sites-available/gitbucket.conf /etc/nginx/sites-enabled/

Next

Please check the Nginx for any syntax errors and yo can do restart the Nginx service with the following command:

nginx -t

And you will see the results of the output as follows

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

systemctl restart nginx

Once you have finish, you can do proceed to the next step.

Access GitBucket Web Interface

GitBucket is now installing and configured.

Please Open your web browsing and type the URL http://your-domain.com. You will be redirected to the following pages

How To Install GitBucket

Now,

Please your click on the Sign in button.

You will be redirected to the login page as shown below:

GitBucketNow

Provide the default in the username and password as root / root and the click on the Sign in button. You should see the GitBucket dashboard in the following pages:

GitBucket

Next
Go to the Account Setting to changes the default root password as shown in the following pages:

GitBucket with Nginx on Ubuntu 18.04 LTS

Congratulations!

you have successfully the installer and configured for GitBucket on Ubuntu 18.04 LTS server.

Have a Nice day “tech-script.com” Share your experience for questions and comments.

Avatar
Welcome to our tech script website, your ultimate destination for tech tutorials, updates, and easy-to-follow installation guides! Whether you're using Windows, macOS, Android, or Linux, we provide step-by-step instructions that anyone can understand.

Leave a Reply