SonarQube Installation – Linux

SonarQube Installation – Linux

SonarQube Server Installation

#!/bin/bash
#title                : Install SonarQube server
#description     : Execute this script as a normal user
#author             : Coding Academi
#date                 : 17012023
#version            : 1.0
#CopyRights     : Coding Acacdemi
#Contact            : 99855 17744

#Hardware Requirements for SonarQube
#—————————————————-

#The SonarQube server requires at least 2GB of RAM to run efficiently and 1GB of free RAM for the OS.

#Login as a root user.
sudo su –

Install Java ( Java is the Pre Requisite Software)
————————————————————–
yum install java-11-openjdk-devel -y
#Download the SonarqQube Server software.
cd /opt
yum install wget unzip -y
wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-9.6.1.59531.zip

unzip sonarqube-9.6.1.59531.zip

mv sonarqube-9.6.1.59531 sonarqube

#As a good security practice, SonarQuber Server is not advised to run sonar service as a root user, so create a new user called sonar user  and grant sudo access to manage nexus services as follows.
useradd sonar

Give the sudo access to sonar user
visudo

sonar   ALL=(ALL)       NOPASSWD: ALL

Change the owner and group permissions to /opt/sonarqube/ directory.
chown -R sonar:sonar /opt/sonarqube/
chmod -R 775 /opt/sonarqube/
su – sonar
cd /opt/sonarqube/bin/linux-x86-64/

./sonar.sh start

Troubleshooting
——————–

sonar service is not starting?

a)make sure you need to change the ownership and group to /opt/sonarqube/ directory for sonar user.
b)make sure you are trying to start sonar service with sonar user.
c)check java is installed or not using java -version command.

Unable to access SonarQube server URL in browser?

a)make sure port 9000 is opened in security groups – AWS ec2 instance.

Create SonarQube server as a sonar service
——————————————————–

ln /opt/sonarqube/bin/linux-x86-64/sonar.sh /etc/init.d/sonar

vi /etc/init.d/sonar

#add below lines in /etc/init.d/sonar

SONAR_HOME=/opt/sonarqube
PLATFORM=linux-x86-64

WRAPPER_CMD=”${SONAR_HOME}/bin/${PLATFORM}/wrapper”
WRAPPER_CONF=”${SONAR_HOME}/conf/wrapper.conf”
PIDDIR=”/opt/sonarqube/”

#Enable the sonar service
sudo systemctl enable sonar

#Start the sonar service
sudo systemctl start sonar

#Check the status of the  sonar service

sudo systemctl status sonar

Post Tags :

Leave a Reply

X