Friday 18 February 2022

SonarQube installation on Ubuntu 20.04

1)  Update System

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

2) Install open-jdk

sudo apt-get install openjdk-11-jdk -y


3) Download the SonarQube software.

cd /opt
sudo wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-7.6.zip


4) Extract SonarQube software

sudo unzip sonarqube-7.6.zip
sudo mv sonarqube-7.6 sonarqube


5) Please change permissions  ( Update user as per requirement )

cd /opt/
sudo chown -R vagrant:vagrant sonarqube

6) Start Sonar

cd /opt/sonarqube/bin/linux-x86-64
./sonar.sh start


You should able to access SonarQube over 9000 port now. By default admin/admin will be credentials for SonarQube.

If you are using VM or Vagrant please enable port forwarding.





7) Enable Sonar as service on Ubuntu
Create sonar service file
sudo vi /etc/systemd/system/sonarqube.service

Add  below content to above file. If you want to change user to run sonarqube process please update User and Group.

[Unit]
Description=SonarQube service
After=syslog.target network.target

[Service]
Type=simple
User=vagrant
Group=vagrant
PermissionsStartOnly=true
ExecStart=/bin/nohup java -Xms32m -Xmx32m -Djava.net.preferIPv4Stack=true -jar /opt/sonarqube/lib/sonar-application-7.6.jar
StandardOutput=syslog
LimitNOFILE=65536
LimitNPROC=8192
TimeoutStartSec=5
Restart=always

[Install]
WantedBy=multi-user.target



8) Start and Enable Sonar Service
sudo systemctl start sonarqube
sudo systemctl enable sonarqube


9) Check SonarQube status to ensure it is working as expected.
sudo systemctl status  sonarqube