How to Install SonarQube in Ubuntu 20.04 LTS


      SonarQube is an open source web based tool to manage code quality and code analysis. It is most widely used in continuous code inspection which performs reviews of code to detect bugs, code smells and vulnerability issues of programming languages such as PHP, C#, JavaScript, C/C++ and Java, also tracks statistics and creates charts that enable developers to quickly identify problems in their code.


  • Ubuntu 20.04 LTS with minimum 2GB RAM and 1 CPU.
  • PostgreSQL Version 9.3 or higher.
  • Apache Tomcat.
  • SSH access with root privileges.
  • Firewall Port: 9000.

Install Java & Configure Java
  • $ sudo apt-get update

  • $ sudo apt install openjdk-11-jdk
    Java Installation

  • $ java -version
    Java Version

  • $ sudo gedit /etc/profile
            Note: add the below 2 line on end of the profile file
            export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
            export PATH=$JAVA_HOME/bin:$PATH

  • $source /etc/profile or source ~/.bashrc
  • $echo $JAVA_HOME

Configure VM Map count & Security limit

  •  $ sudo sysctl -w vm.max_map_count=262144
  •  $ sudo sysctl -w fs.file-max=65536
    Vm Map

  •  $ sudo vi /etc/security/limits.conf 

         #Add the below line end of the line and save the file.
          sonarqube   -   nofile   65536
          sonarqube   -   nproc    4096

Install and Setup PostgreSQL 10 Database for SonarQube

  • Create the file “/etc/apt/sources.list.d/pgdg.list” and add the corresponding line for the repository in it:

     $ sudo sh -c 'echo "deb $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

  • Import the repository signing key and update the package lists:

$ wget --quiet -O - | sudo apt-key add –

  • added the PostgreSQL official repository to our system

                      $ sudo apt-get update

  • To install PostgreSQL on Ubuntu, use the apt-get (or other apt-driving) command:

                     $ sudo apt-get -y install postgresql


  •   Update Postgres account Password

                    $ sudo passwd postgres

Postersql Password set

                    $ su – postgres


Postgres Login

  • Create a user and database for Sonarqube

            postgres@manikandan-VirtualBox: $ createuser sonar

             postgres@manikandan-VirtualBox:~$ psql



            postgres=# ALTER USER sonar WITH ENCRYPTED password 'sonar123';

Alter User


            postgres=# CREATE DATABASE sonarqube OWNER sonar;

Create DB

           postgres=# grant all privileges on DATABASE sonarqube to sonar;

Grant Access

           postgres=# exit

           postgres@manikandan-VirtualBox:~$ exit

Exit Psql

Install and configure SonarQube

  • $ sudo wget
    Download SonarQube

  • $ sudo unzip
    unzip sonarqube

  • $ sudo mv sonarqube- /opt
  • $ cd /opt
  • $ cd sonarqube-
    Move Files

  • $ sudo gedit

           Remove the # symbol on the below line in




             sonar.web.javaOpts=-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError






  • $ ./sonarqube- status
    Check status

  • $ sudo ./sonarqube- start
    Start service

  • Open http://localhost:9000 on web browser

       Note: if the connection not established, check the Apache tomcat running status.

     Default Login:

                UserName : admin

                Password : admin


PDF for Document available to Download


Happy learning and provide the valuable feedback as comments


Popular posts from this blog

Azure AZ-104 Exam Dump

Get Free Microsoft Certification Exams Vouchers

Microsoft Azure Fundamental AZ-900 Question & Answer