Blog Detail

Covid-19 Tracker Ask Question

preview image DevOps
by Anurag Srivastava, May 12, 2018, 4:47:07 PM | 4 minutes |

SonarQube installation on Ubuntu

If you have not read my previous blog on SonarQube then please click here to access it.

My previous blog: Why SonarQube is important for IT projects ?

In my previous blog on SonarQube, I had explained why it is important for IT projects and what are the benefits of using SonarQube. Now I will explain the installation process of SonarQube on Ubuntu operating system.

System Requirement:

For installing SonarQube we have following prerequisites:

  • Ubuntu operating system (tested on 16.04).
  • 4 GB of RAM.
  • Non-root user with sudo privileges.

Whenever we are going to install any software it is recommended to update the base system with latest version. We can do it by running:

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

Install Java:

Install Java if it is not installed on your machine. To install it we have to run following commands:
Add Oracle Java repository

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update

After that we can install Java 8

sudo apt install oracle-java8-installer

We can verify the Java version

java -version

Install MySQL:

We need MySQL setup to run SonarQube. We can install MySQL through following command:

sudo apt install mysql-server mysql-client

Once MySQL is installed successfully we can login to MySQL server:

mysql -u root -p

After logging into MySQL server we need to create the database sonarqube:

create database sonar;

Now as we have installed Java and MySQL and created the sonarqube database, lets install SonarQube.

Install SonarQube:
Download the latest version of SonarQube from their official website:


Unzip the downloaded file.

sudo unzip -d /opt

Rename the directory to sonar

cd /opt
sudo mv sonarqube-7.1 sonar

Now we need to edit the SonarQube configuration file.

sudo vim /opt/sonar/conf/

After opening the file make following changes:


These are the three main changes which is required in order to connect it through the MySQL database. Save the file and close.

Issue with SonarQube 7.1:

Now we are set with SonarQube installation but there is an issue in version 7.1 as we can not run this with root user and after starting it stops automatically. I have faced the issue and done lot of back and forth to solve the problem and finally got the solution.

We need to create a user and group and then change the installation directory rights.

First of all create a group as sonar

sudo groupadd sonar

Now add the user with directory access

sudo useradd -c "user to run SonarQube" -d /opt/sonar -g sonar sonar 
sudo chown sonar:sonar /opt/sonar -R
Edit the sonar script file and set RUN_AS_USER
sudo vim  /opt/sonar/bin/linux-x86-64/

Save and close the file.

Start SonarQube:

Now to start SonarQube we need to do following:
Switch to sonar user

sudo su sonar

Move to the script directory

cd /opt/sonar/bin/linux-x86-64/

Run the script to start SonarQube

./ start

We can also add this in service and can run as a service.

Access SonarQube:
You can access the SonarQube by opening the browser and typing:


Please have some patience as it will take 1-2 minute to start so wait and refresh.

So here I have covered the complete process to install SonarQube on Ubuntu operating system. In my next blog I would like to cover the functionality of SonarQube and how can we setup the project and scan them for the analysis.

In case you face any difficulty in installing SonarQube please leave a comment, I will reply.

If you want to know the Jenkins and SonarQube installation process and configuration then refer to my previous blog:

Why SonarQube is important for IT projects ? 

Configure Jenkins for Automated Code Deployment
Install Jenkins on Ubuntu  
Configure SonarQube Scanner with Jenkins

Analyze your project with SonarQube

In case of any suggestion or query please leave the comment.

Comments (16)

  • user image
    Sarita Yadav
    May 12, 2018, 5:24:25 PM


  • user image
    Anurag Srivastava
    May 13, 2018, 1:54:54 PM

    Thanks. :)

  • user image
    Rocky Paul
    May 13, 2018, 5:14:25 PM

    Nice blog.

  • user image
    Anurag Srivastava
    May 15, 2018, 5:21:21 PM

    Thanks :)

  • user image
    Ravi Geetha Vandana
    Mar 25, 2019, 1:02:33 PM

    i have an issue with login in sonarquebe could you please help me

  • user image
    Anurag Srivastava
    Mar 25, 2019, 3:30:39 PM

    @Ravi Geetha Vandana: You can ask your query here.

  • user image
    krishna priya
    Mar 28, 2019, 1:30:18 PM

    in my terminal sonarqube was started but using localhost:9000 it is not opening in browser

  • user image
    Anurag Srivastava
    Mar 28, 2019, 3:49:34 PM

    @krishna: Can you check if your 9000 port is available?

  • user image
    Anurag Srivastava
    Mar 28, 2019, 6:31:11 PM

    @krishna: Can you check if your 9000 port is available?

  • user image
    krishna priya
    Mar 29, 2019, 1:27:35 PM

    9000 port is in closed state how to change it's state

  • user image
    Anurag Srivastava
    Mar 29, 2019, 7:37:30 PM

    @Krishna: Try to change the port using sonar.web.port setting in your file. After that restart the sonar service and try to access. Let me know if this works for you.

  • user image
    ravi chandra
    Apr 24, 2019, 7:07:59 AM

    http://localhost:9000 I'm able to access from the terminal, But not able to access from the browser. (http://privateip:9000 not able to access) Please help on it

  • user image
    ravi chandra
    Apr 24, 2019, 7:59:29 AM

    Anurag Srivastava your post helped me a lot thank you I have fixed by restarting sonarqube

  • user image
    Anurag Srivastava
    Apr 24, 2019, 8:02:51 AM

    Ravi: Thanks for the update. Good to know that this blog has helped you to configure SonarQube.

  • user image
    Rajasekhar Reddy
    Aug 28, 2019, 7:21:11 AM When i hit the above URL getting the error message as "Repository path missing or not specified." HTTP request sent, awaiting response... 404 Not Found 2019-08-28 07:19:57 ERROR 404: Not Found. Please help me to get download in ubuntu 16.04

  • user image
    Anurag Srivastava
    Sep 3, 2019, 2:06:36 PM

    Hi Rajasekhar, you can download the latest one from the following link:

Leave a comment

Related Blogs

Introduction to Cloud Computing

Sep 23, 2020, 2:38:00 PM | Anurag Srivastava

Monitoring website uptime using Kibana

Sep 6, 2020, 5:20:33 PM | Anurag Srivastava

Monitoring Application using Elastic APM

Jan 16, 2020, 11:43:29 AM | Anurag Srivastava

Configuring Django application with Elastic APM

Jan 14, 2020, 10:22:34 AM | Anurag Srivastava

Introduction to Elastic APM

Jan 7, 2020, 7:15:34 PM | Anurag Srivastava

Why monitoring is important?

Jan 6, 2020, 7:30:13 PM | Anurag Srivastava

Top Blogs

Configure SonarQube Scanner with Jenkins

Jun 21, 2018, 4:58:11 AM | Anurag Srivastava

Execute Commands on Remote Machines using sshpass

Jul 16, 2018, 5:00:02 PM | Anurag Srivastava

Importing MongoDB data into Elasticsearch

Mar 9, 2019, 8:20:38 AM | Anurag Srivastava

Importing MySQL data into Elasticsearch

Feb 9, 2019, 12:06:18 PM | Anurag Srivastava

Configure Jenkins for Automated Code Deployment

Jun 13, 2018, 3:44:01 PM | Anurag Srivastava

Deploying Angular code using Python script

Jun 26, 2018, 4:50:18 PM | Anurag Srivastava