Skip to content

TechDirectArchive

Hands-on IT, Cloud, Security, Veeam & DevOps

  • Home
  • About
  • Advertise With US
  • Contact
  • Reviews
  • Toggle search form

How to Install SonarQube on Ubuntu 20.04 LTS

Posted on 30/03/202422/02/2025 Imoh Etuk By Imoh Etuk No Comments on How to Install SonarQube on Ubuntu 20.04 LTS
  1. Home
  2. Network | Monitoring
  3. How to Install SonarQube on Ubuntu 20.04 LTS
How-to-Install-SonarQube-on-Ubuntu-LTS

SonarQube is a free, web-based tool for analyzing the quality of code. Through plugins, SonarQube can evaluate a variety of code written in several programming languages. In this tutorial, you will learn how to Install SonarQube on Ubuntu 20.04 LTS. Please see how to change the Windows Pagefile Size, how to Change Active Directory Domain name from dot local to dot com, and how to Install PostgreSQL on Windows server as Veeam Database Engine.

The SonarQube tool is made up of two parts: a local scanner that will be installed on the developer’s machine and used to analyze the code, and a central server that will be used to store information and produce results.

A single SonarQube server installation may support many scanners, enabling you to centralize code quality reports from numerous developers. The SonarQube server requires Java version 11, while the SonarQube scanners require Java version 11 or 17.

SonarQube is able to analyze any kind of Java source files regardless of the version of Java they comply with. We recommend using the Critical Patch Update (CPU) releases.

See How to integrate AWS CodeBuild and AWS CodeCommit to SonarCloud, how to Install PostgreSQL on Windows server as Veeam Database Engine, and How to Upgrade From Ubuntu 20.04 LTS to 22.04 LTS.

Prerequisites for installing SonarQube on Ubuntu

  1. This is an Ubuntu 20.04 LTS server with 2GB or more memory and 1 vCPU core.
  2. A sudo non-root user and a firewall
  3. Oracle Java 11 is installed on the server.
  4. Nginx and MySQL
  5. Certbot (the Let’s Encrypt client)
  6. A fully-qualified domain name and an A record directing traffic towards the server where SonarQube would be installed. For this tutorial, we will use the domain name sonarqube.demo.com

Hardware Requirements

As stated on the official SonarQube documentation page, the following hardware requirements must be met.

  1. A small-scale (individual or small team) instance of the SonarQube server requires at least 2GB of RAM to run efficiently and 1GB of free RAM for the OS. If you are installing an instance for large teams or enterprises, please consider the additional recommendations below.
  2. The amount of disk space you need will depend on how much code you analyze with SonarQube.
  3. SonarQube must be installed on hard drives that have excellent read and write performance. Most importantly, the “data” folder houses the Elasticsearch indices on which a huge amount of I/O will be done when the server is up and running. Great read & write hard drive performance will therefore have a great impact on the overall SonarQube server performance.
  4. SonarQube does not support 32-bit systems on the server side. SonarQube does, however, support 32-bit systems on the scanner side.

Install SonarQube on Ubuntu 20.04 LTS

Follow the steps below to install SonarQube on Ubuntu. Please see Install Veeam Backup and Replication with the default PostgreSQL, and how to Fix unable to login to Trellix ePO with Windows authentication.

Step 1 – Update the Package Manager

Run sudo apt-get update and to update the system package manager. In addition, you need to also run sudo apt install mtools to install all the necessary tools on your system.

Update-Package-manager
Install-all-the-tools
Update package manager and install mtools

Run the command below to install net-tools for Linux:

sudo apt install net-tools unzip vim curl
Install-Nodejs-packages
Install Net-Tools

 Step 2-Install Java OpenJDK

One of the requirements for installing and configuring SonarQube on Ubuntu 20.04, is Java. To install Java OpenJDK, run the command below:

sudo apt install openjdk-11-jdk
Install-JavaJdk
Installing Java OpenJDK

You the below command to increase the Virtual memory and reboot your system to apply changes.

sudo sysctl -w vm.max_map_count=524288
sudo sysctl -w fs.file-max=131072
ulimit -n 131072
ulimit -u 8192
Increase-Virtual-Memory
Ulimit
Increase Virtual Memory

 Step 3- Create a user for Sonarqube

We will create a new user to access only the Sonarqube installation because the most recent version of Sonar cannot be operated under root user privileges. Use the useradd command to create a user named sonar and set the password with the passwd command.

sudo useradd sonar
sudo passwd sonar
Create-user-and-set-Password
Creating and setting a user password

Please feel free to use any username you prefer to use.

Step 4 – Install PostgreSQL Database

The most recent version of PostgreSQL is not available in Ubuntu’s base repository; therefore, we must manually add its repository in order to obtain it. Here’s the order to carry it out. To do so, first add the GPG key using the command below:

wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O- | sudo apt-key add -
Add-GPG-key
Adding GPG key

Now add the repo: 

echo "deb [arch=amd64] http://apt.postgresql.org/pub/repos/apt/ focal-pgdg main" | sudo tee /etc/apt/sources.list.d/postgresql.list
Add-the-repo
Adding Repo

Next, update the system package manager once again by running the sudo apt update command

Update-system
Updating System

Now, let’s install the PostgreSQL Server by running the command below:

sudo aptitude -f install postgresql postgresql-contrib
Install-postgresql
Installing the PostgreSQL Server

You can check the status of  its service using 

sudo systemctl status postgresql
Check-the-PostgreSQL-Server-status
Checking the PostgreSQL Server Status

Step 5 – Create a database for Sonar

Let’s build a PostgreSQL database for SonarQube after the installation is finished, but first, specify a password:

sudo passwd postgres
Create-a-Database-for-PostgreSQL
Setting up password for Postgres user

Switch to postgres the user. Use the password you have set above.

su-postgres

Create a new user who will have access to the SonarQube database now with the command below:

createuser sonardatabaseuser

Now switch to the PostgreSQL shell.

psql

Set a password for a newly created user using the syntax shown below to safeguard it:

ALTER USER sonardatabaseuser WITH ENCRYPTED password 'yourpassword';

Run the following command to create a brand-new PostgreSQL database:

CREATE DATABASE sonardb OWNER sonardatabaseuser;
Create-a-database-for-sonarqube-database-user
Create a database for the User

Now  exit from the psql shell by running \q and go back to the system user with the exit command

Step 7 – Download and Setup SonarQube on Ubuntu 20.04 LTS

The most recent version of SonarQube was v-9.5.0.56709 as this article was being written. To obtain the most recent version, you can, however, go straight to the official website.

You can alternatively go to the download page and use the wget command to copy the link to download, like we have done here:

sudo wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-9.5.0.56709.zip
Install-Sonarqube
Installing SonarQube

Extract the file using the unzip command. If you don’t already have the unzip command installed on your system, run sudo apt install unzip to install it as shown here:

Install-Unzip-command
Installing the unzip command

Now extract the zip file and delete the zip format from the /opt directory. Using the command below:

sudo unzip sonarqube-9.5.0.56709.zip
sudo rm sonarqube-9.5.0.56709.zip

Note, you have to change directory to the /opt directory if you didn’t download the file there

Removed-Zip-file
Removing the zip file

Step 8 – Configuring Database for Sonar

We need to configure the database by opening the configuration file with a text editor of our choice. Here Nano text editor is what we’re using:

sudo nano /opt/sonarqube/conf/sonar.properties
Add-the-username-and-password

Change the username and password to the ones your set while creating the database as shown on the screenshot above.

sonaruser – is a database username
yourpassword – is the database password

To save and exit the Nano text editor- press Ctrl+X and then type- Y and hit the Enter key.

Step 9 – Create SonarQube Systemd service file

Sonarqube will not by default have a service file to start it when the system boots and in the background. To do this, edit the /etc/systemd/system/sonar.service file with a text editor.

sudo nano /etc/systemd/system/sonar.service
Past-the-Systemd-file
Creating the Systemd file

Copy and paste the command below as shown in the screenshot above:

[Unit]
Description=SonarQube service
After=syslog.target network.target

[Service]
Type=forking
ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start
ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop
LimitNOFILE=131072
LimitNPROC=8192
User=sonarh2s
Group=sonarh2s
Restart=on-failure

[Install]
WantedBy=multi-user.target

Reload daemon with the below command:

sudo systemctl daemon-reload

Then start and enable the service with:

sudo systemctl enable sonar 
sudo systemctl start sonar
Enable-and-start-sonar
Enable and start SonarQube

Check now to see if the create SonarQube service is active with the command below:

I hope you found this article useful on “how to Install SonarQube on Ubuntu 20.04 LTS”. Please feel free to leave a command below.

5/5 - (1 vote)

Thank you for reading this post. Kindly share it with others.

  • Share on X (Opens in new window) X
  • Share on Reddit (Opens in new window) Reddit
  • Share on LinkedIn (Opens in new window) LinkedIn
  • Share on Facebook (Opens in new window) Facebook
  • Share on Pinterest (Opens in new window) Pinterest
  • Share on Tumblr (Opens in new window) Tumblr
  • Share on Telegram (Opens in new window) Telegram
  • Share on WhatsApp (Opens in new window) WhatsApp
  • Share on Mastodon (Opens in new window) Mastodon
  • Share on Bluesky (Opens in new window) Bluesky
  • Share on Threads (Opens in new window) Threads
  • Share on Nextdoor (Opens in new window) Nextdoor
Network | Monitoring

Post navigation

Previous Post: How to Sync Data in Cloud Drives to Synology NAS
Next Post: How to Install Hadoop on Linux

Related Posts

  • ACMP Defender Management
    How to Manage Microsoft Defender Antivirus with Argon ACMP Network | Monitoring
  • cisco asa 5510
    Copying TFTP Image to Flash Network | Monitoring
  • Featured image Two Factor Authentication
    Change Two-Factor Authentication in Microsoft 365/Office 365 Network | Monitoring
  • Private and Public networks in Windows to VPN
    The differences between Private and Public networks in Windows to VPN? Network | Monitoring
  • banner
    How to Check and Reset Network Data Usage in Windows 11 Network | Monitoring
  • creating the perfect grafana dashboard  main
    How to install Grafana on Ubuntu Linux Network | Monitoring

More Related Articles

ACMP Defender Management How to Manage Microsoft Defender Antivirus with Argon ACMP Network | Monitoring
cisco asa 5510 Copying TFTP Image to Flash Network | Monitoring
Featured image Two Factor Authentication Change Two-Factor Authentication in Microsoft 365/Office 365 Network | Monitoring
Private and Public networks in Windows to VPN The differences between Private and Public networks in Windows to VPN? Network | Monitoring
banner How to Check and Reset Network Data Usage in Windows 11 Network | Monitoring
creating the perfect grafana dashboard  main How to install Grafana on Ubuntu Linux Network | Monitoring

Leave a Reply Cancel reply

You must be logged in to post a comment.

Microsoft MVP

VEEAMLEGEND

vexpert-badge-stars-5

Virtual Background

GoogleNews

Categories

veeaam100

Veeam Vanguard

  • BitLocker 1
    Unable to install Microsoft Bitlocker Administration: Uninstall your current version of MBAM and run setup again Windows
  • image 12
    How to Use Postman with the Amazon Pinpoint API AWS/Azure/OpenShift
  • Banner
    Enabling and Configuring WinRM via GPO Windows
  • Burn ISO on MAC   Proxmox installation
    Create a bootable USB on Mac: Proxmox VE Setup Virtualization
  • banner2
    How to Integrate Postman With GitHub Automation
  • We cannot fine camera
    Fix we could not find a camera compatible with Windows Hello Face Windows
  • Route53AWS
    Set up and configure Route 53 for your Domain in AWS AWS/Azure/OpenShift
  • Create AWS RDS instance
    How to create an Amazon Relational Database Service Instance AWS/Azure/OpenShift

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,801 other subscribers
  • RSS - Posts
  • RSS - Comments
  • About
  • Authors
  • Write for us
  • Advertise with us
  • General Terms and Conditions
  • Privacy policy
  • Feedly
  • Telegram
  • Youtube
  • Facebook
  • Instagram
  • LinkedIn
  • Tumblr
  • Pinterest
  • Twitter
  • mastodon

Tags

AWS Azure Bitlocker Microsoft Windows PowerShell WDS Windows 10 Windows 11 Windows Deployment Services Windows Server 2016

Copyright © 2025 TechDirectArchive

Loading Comments...

You must be logged in to post a comment.