Skip to content

TechDirectArchive

Hands-on IT, Cloud, Security & DevOps Insights

  • Home
  • About
  • Advertise With US
  • Reviews
  • Contact
  • Toggle search form
Home » Network | Monitoring » How to Install SonarQube on Ubuntu 20.04 LTS
  • powershell auto run
    How to pause a PowerShell script Windows
  • Delete Edit or Revert a Snapshot on vSphere
    Manage VMware Snapshots: Delete or Edit or Revert a Snapshot Virtualization
  • maxresdefault
    Linux Directory Hierarchy Linux
  • Get certificate thumbprint
    Retrieve an SSL Thumbprint in Windows using PowerShell Scripts
  • Err connection timed out DNS
    How to Fix Err Connection Timed Out DNS Error Windows
  • Featured image What are system partition and boot partitions in Windows
    What are System Partition and Boot Partition in Windows? Windows
  • Azure DevOps Server
    How to Install Azure DevOps Server 2022 Automation
  • Veeam
    Failed to connect to Veeam Backup and Replication server: Remote Channel Sink UriNotPublished, remote connection refused, and failed to start the service Backup

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
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.

  • Click to share on X (Opens in new window) X
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Pinterest (Opens in new window) Pinterest
  • Click to share on Tumblr (Opens in new window) Tumblr
  • Click to share on Telegram (Opens in new window) Telegram
  • Click to share on WhatsApp (Opens in new window) WhatsApp
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on Bluesky (Opens in new window) Bluesky
  • Click to share on Threads (Opens in new window) Threads
  • Click to 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

  • WinRM and Kerberos Delegation troubleshooting
    Troubleshooting WinRM and Kerberos Delegation for WAC Network | Monitoring
  • increaseEmailsize
    Email Size Limits: Boost for High Profile Users in Exchange 2010 Network | Monitoring
  • banner 1
    How to Hide or Block Wi-Fi Networks on Windows Network | Monitoring
  • Screenshot 2020 05 19 at 02.50.47
    Fix Administrative templates retrieved from the local computer does not show up Network | Monitoring
  • screenshot 2020 05 03 at 18.30.44
    How to Activate Cisco ASA 5505 License Network | Monitoring
  • Screenshot 2020 06 22 at 10.17.18
    How to disable Outlook and Yahoo Auto-Complete Network | Monitoring

More Related Articles

WinRM and Kerberos Delegation troubleshooting Troubleshooting WinRM and Kerberos Delegation for WAC Network | Monitoring
increaseEmailsize Email Size Limits: Boost for High Profile Users in Exchange 2010 Network | Monitoring
banner 1 How to Hide or Block Wi-Fi Networks on Windows Network | Monitoring
Screenshot 2020 05 19 at 02.50.47 Fix Administrative templates retrieved from the local computer does not show up Network | Monitoring
screenshot 2020 05 03 at 18.30.44 How to Activate Cisco ASA 5505 License Network | Monitoring
Screenshot 2020 06 22 at 10.17.18 How to disable Outlook and Yahoo Auto-Complete 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

sysadmin top30a

  • powershell auto run
    How to pause a PowerShell script Windows
  • Delete Edit or Revert a Snapshot on vSphere
    Manage VMware Snapshots: Delete or Edit or Revert a Snapshot Virtualization
  • maxresdefault
    Linux Directory Hierarchy Linux
  • Get certificate thumbprint
    Retrieve an SSL Thumbprint in Windows using PowerShell Scripts
  • Err connection timed out DNS
    How to Fix Err Connection Timed Out DNS Error Windows
  • Featured image What are system partition and boot partitions in Windows
    What are System Partition and Boot Partition in Windows? Windows
  • Azure DevOps Server
    How to Install Azure DevOps Server 2022 Automation
  • Veeam
    Failed to connect to Veeam Backup and Replication server: Remote Channel Sink UriNotPublished, remote connection refused, and failed to start the service Backup

Subscribe to Blog via Email

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

Join 1,841 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.