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.
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 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
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.
Download the latest version of SonarQube from their official website:
Unzip the downloaded file.
sudo unzip sonarqube-7.1.zip -d /opt
Rename the directory sonarqube-7.1.zip to sonar
sudo mv sonarqube-7.1 sonar
Now we need to edit the SonarQube configuration file.
sudo vim /opt/sonar/conf/sonar.properties
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 sonarEdit the sonar script file and set RUN_AS_USER
sudo chown sonar:sonar /opt/sonar -R
sudo vim /opt/sonar/bin/linux-x86-64/sonar.sh
Save and close the file.
Now to start SonarQube we need to do following:
Switch to sonar user
sudo su sonar
Move to the script directory
Run the script to start SonarQube
We can also add this in service and can run as a service.
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:
Install Jenkins on Ubuntu
Configure SonarQube Scanner with Jenkins
In case of any suggestion or query please leave the comment.
Author | Blogger | Tech Lead | Elastic Stack | Innovator |View Profile
Mar 9, 2019, 8:20:38 AM | Anurag Srivastava
Feb 9, 2019, 6:34:22 PM | Anurag Srivastava
Jan 31, 2018, 6:11:29 AM | Anurag Srivastava
Apr 14, 2018, 1:18:05 PM | Anurag Srivastava
Feb 9, 2019, 12:06:18 PM | Anurag Srivastava
Oct 13, 2018, 8:49:59 PM | Anurag Srivastava
Jun 21, 2018, 4:58:11 AM | Anurag Srivastava
Jun 26, 2018, 4:50:18 PM | Anurag Srivastava
May 12, 2018, 4:47:07 PM | Anurag Srivastava
Jul 16, 2018, 5:00:02 PM | Anurag Srivastava
Jul 12, 2018, 7:40:51 PM | Anurag Srivastava
Aug 14, 2018, 4:47:56 PM | Anurag Srivastava