There is a point to this story, but it has temporarily escaped my mind...
Contact Me MyFaceBook MyLinkedIn MyGitHub MyTwitter

Install SonarQube

SonarQube is a free and open source quality management software that can be used to automate code quality inspections.

Make sure that all of the latest patches are installed.

sudo apt update
sudo apt dist-upgrade
sudo reboot

Install Install Java

Install PostgreSQL and configure:

echo "deb `lsb_release -cs`-pgdg main" | tee /tmp/postgresql.list
sudo mv /tmp/postgresql.list /etc/apt/sources.list.d/
wget -q -O - | sudo apt-key add -
sudo apt update
sudo apt install postgresql postgresql-contrib -y
sudo systemctl start postgresql
sudo systemctl enable postgresql
sudo su - postgres
CREATE USER sonar WITH ENCRYPTED password 'P@ssword';

Download, install, and configure SonarQube:

sudo apt install unzip -y
cd /tmp
sudo unzip sonarqube-$ -d /opt
if [ -d "/opt/sonarqube" ]; then
  sudo rm /opt/sonarqube
sudo ln -s /opt/sonarqube-$VERSION /opt/sonarqube
sudo sed -i 's/#sonar.jdbc.username=/sonar.jdbc.username=sonar/g' /opt/sonarqube/conf/
sudo sed -i 's/#sonar.jdbc.password=/sonar.jdbc.password=P@ssword/g' /opt/sonarqube/conf/
sudo sed -i 's/#sonar.jdbc.url=jdbc:postgresql:\/\/localhost\/sonar/sonar.jdbc.url=jdbc:postgresql:\/\/localhost\/sonar/g' \
sudo sed -i 's/ -Xmx512m/  -Xmx512m/g' \
sudo sed -i 's/' /opt/sonarqube/conf/
sudo groupadd sonar
sudo useradd -c "Sonar System User" -d /opt/sonarqube -g sonar -s /bin/bash sonar
sudo chown -R sonar:sonar /opt/sonarqube-$VERSION
sudo sed -i 's/#RUN_AS_USER=/RUN_AS_USER=sonar/g' /opt/sonarqube/bin/linux-x86-64/
sudo sysctl -w vm.max_map_count=262144

Configure the service:

cat > /tmp/sonar.service << EOF
Description=SonarQube Server
ExecStart=/opt/sonarqube/bin/linux-x86-64/ start
ExecStop=/opt/sonarqube/bin/linux-x86-64/ stop
sudo mv /tmp/sonar.service /etc/systemd/system/
sudo chown root:root /etc/systemd/system/sonar.service
sudo systemctl enable sonar.service
sudo systemctl start sonar.service

Install NGINX web server

Configure NGINX to proxy web traffic to SonarQube:

cat > /tmp/sonar-proxy<< EOF
server {
    listen 80;
    location / {
sudo mv /tmp/sonar-proxy /etc/nginx/sites-available/
sudo ln -s /etc/nginx/sites-available/sonar-proxy /etc/nginx/sites-enabled/sonar-proxy
sudo service nginx reload

SonarQube is now installed and configured. Open a web browser and navigate to the URL. Click on the Log In button and provide the default administrator account username and password as admin/admin and click on the Log In button. You should see the SonarQube default dashboard.

Last Updated: January 28, 2019

Copyright © 2022 by Julian Easterling. SOME RIGHTS RESERVED.
Privacy Policy              Terms of Use             

Creative Commons License
Except where otherwise noted, content on this site is
licensed under a Creative Common Attribution-Share Alike 4.0 International License.

All of the opinions expressed on this website are those of Julian Easterling and
do not represent the views of any of my current and previous clients or employers in any way.

If you notice an error on the site or content that has not been properly attributed, bring
it to my attention using the contact page and I will endeavor to fix it as soon as I can.

I accept no responsibility or liability for any damages incurred by following any of
my advice or by using any of the information on my site or of those sites that I link to.