SonarQube is an Open-Source, Java based Code Analysis Tool. It is used to detect bugs, security vulnerabilities, and other code quality issues. It uses database like MS SQL, Oracle or PostgreSQ for storing analysis results. So, in this tutorial we will use open-source database PostgreSQL.
Pre-requistes
Instance with at least 2 GB RAM
Install Java
To configure the SonarQube server, you need to install Java. To install Java, follow the command below:
Then press ESC and and enter :wq! to come out of the above screen.
Kernel System changes
Now we need to change the kernel system settings. To do it run following commands:
1
sudo vim /etc/sysctl.conf
Then add the following lines to the sysctl.conf file:
1 2
vm.max_map_count=262144 fs.file-max=65536
Then press ESC and and enter :wq to come out of the above screen.
Next, we’re going to edit limits.con. Open that file with the command:
1
sudo vim /etc/security/limits.conf
Then add the following lines to the limits.conf file:
1 2
sonar - nofile 65536 sonar - nproc 4096
Then press ESC and and enter :wq! to come out of the above screen.
Reload SonarQube
Now we need to reload system level changes without server boot to do it run follwing command:
1
sudo sysctl -p
Start SonarQube
Now we need to start SonarQube. To do it run following command:
1 2 3
sudo systemctl start sonar
sudo systemctl enable sonar
Check SonarQube Status
Now we need to check SonarQube status. To do it run following command:
1
sudo systemctl status sonar
To check the Sonar logs to make sure there is no error:
1
tail -f /opt/sonarqube/logs/sonar*.log
Access the web interface
To acces the web interface, you ned to navigate to
1
http://your_sonarqube_public_dns_name:9000/
Video Tutorial
You can find the YouTube tutorial from this link.
Conclusion
In this tutorial, we learned how to install SonarQube on Ubuntu. If you have any issue regarding this tutorial, mention your issue in comment section or reach me through my E-mail.