How to Install SonarQube 8.4 on Debian 10

SonarQube describe itself as code quality and security. Installing SonarQube maybe a little intimidating for beginner, since it not support SSL by default we’ll need to use Nginx reverse proxy in front.


Setup DNS record on your DNS hosting, here’s what I set on Cloudflare
setup sonarqube dns settings
We’ll setup Lets Encrypt SSL later after everything installed.

Update Debian 10

As usually, update and upgrade the packages to the latest available version.

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

Install Dependency

We’ll install dependency first, so we wont have any problem with errors like ‘wget not found’

sudo apt-get install wget unzip curl gnupg2 ca-certificates lsb-release socat -y

depend on how you install Debian 10, if you using some vps/cloud provider already had them installed.

Install Java 11

Install Java 11 on Debian 10

sudo apt-get install openjdk-11-jre -y

Install PostgreSQL

Our SonarQube instalation will using PostgreSQL as database. Add PostgreSQL repository

sudo sh -c 'echo "deb `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
wget -q -O - | sudo apt-key add -
sudo apt update

install PostgreSQL 12

sudo apt-get install postgresql postgresql-contrib -y

start PostgreSQL services on booting

sudo systemctl enable postgresql

start PostgreSQL services right now

sudo systemctl start postgresql

update password for postgres user

sudo passwd postgres

update sonarqube password
Create sonarqube user and database
1. Login as postgres user

sudo su postgres

2. Create user sonarqube. We’ll named our user sonarqube

createuser sonarqube

3. Set password for sonarqube user
Run the PostgreSQL shell


set the password, dont forget to change PASSWORD to more secure password, for example dpztrxHrfMpb4P9vvMsdLfPcPTxj9N


postgresql shell debian 10
4. Create database
Still on postgre shell, create new database sonarqube

CREATE DATABASE sonarqube OWNER sonarqube;

close the postgres shell and back to your user account.
exit postgres shell

Download SonarQube

Current SonarQube version is 8.4.1, the following command may not working. If that happen check SonarQube Download page


Extract the zip file to /opt directory

sudo unzip -d /opt/

rename the folder to /opt/sonarqube

sudo mv /opt/sonarqube- /opt/sonarqube

Update database credential on /opt/sonarqube/conf/ file


Systemd Services

Change the file permission to your current user, in this example we’re using atetux

sudo chown atetux:atetux -R /opt/sonarqube

set file permission to current user

Create systemd files for sonarqube at /etc/systemd/system/sonarqube.service

Description=SonarQube Service
ExecStart=/opt/sonarqube/bin/linux-x86-64/ start
ExecStop=/opt/sonarqube/bin/linux-x86-64/ stop
 # change to your user

run the sonarqube service on reboot

sudo systemctl enable sonarqube

run the sonarqube services

sudo systemctl start sonarqube

Install Letsencrypt SSL

Login as root user and executing following command.

curl | sh
# update the .bashrc
source ~/.bashrc

Generate SSL --issue -d --standalone

letsencrypt ssl

Install Nginx

sudo apt-get install nginx -y

Create new file for sonarqube /etc/nginx/sites-enabled/

server {
    listen 443 ssl http2;
    proxy_buffers 16 64k;
    proxy_buffer_size 128k;
    ssl_certificate /root/;
    ssl_certificate_key /root/;
    ssl_session_timeout 1d;
    ssl_session_cache shared:MozSSL:10m;  # about 40000 sessions
    ssl_session_tickets off;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers off;
    # HSTS (ngx_http_headers_module is required) (63072000 seconds)
    add_header Strict-Transport-Security "max-age=63072000" always;
    location / {
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
        proxy_redirect off;
        proxy_set_header    Host            $host;
        proxy_set_header    X-Real-IP       $remote_addr;
        proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header    X-Forwarded-Proto http;

Restart nginx

systemctl restart nginx

enable nginx on boot

systemctl enable nginx

Open your domain for example I use
sonarqube first login
Login with default credential

username : admin
password : admin
sonarqube admin login first time
remmember to change the password after first login.

2 thoughts on “How to Install SonarQube 8.4 on Debian 10”

Leave a Comment