Step 1:
======
Install Java 17 using Amazon Corretto
SonarQube 9.9.8 requires Java 17.
sudo rpm --import [Link]
sudo curl -Lo /etc/[Link].d/[Link] [Link]
sudo yum install -y java-17-amazon-corretto-devel --nogpgcheck
Verify:
java -version
Step 2:
=======
Install wget and unzip
sudo yum install wget unzip -y
Step 3:
=====
Download and Extract SonarQube
cd /opt
sudo wget [Link]
[Link]
sudo unzip [Link]
sudo mv sonarqube-9.9.8.100196 SonarQube
Step 4:
=======
Create a Dedicated User
For security, SonarQube must not be run as root.
sudo useradd -m -d /opt/sonarqube -s /bin/bash sonar
The -m flag is meant to create the directory, but if /opt/sonarqube already exists,
it won't touch or overwrite it.
It will just assign that directory as the home directory of the sonar user.
It will show a warning, not an error — and that’s fine.
-s /bin/bash sets the default shell for the sonar user.
It just means: when you log in as sonar, you'll get a normal bash shell
environment.
Step 5:
======
Set Ownership
sudo chown -R sonar:sonar /opt/SonarQube
This ensures the sonar user has the right permissions to manage and run SonarQube.
Now, the sonar user can run the bin/ startup scripts directly — no need to add it
to sudoers or use visudo.
it can run the bin/ startup scripts without needing visudo or sudo access.
Step 6:
=======
Configure Java for Sonar User
Switch to the sonar user:
sudo su - sonar
Edit the profile:
------------------
vi ~/.bash_profile
Add at the bottom:
export JAVA_HOME=/usr/lib/jvm/java-17-amazon-corretto
export PATH=$JAVA_HOME/bin:$PATH
Save and
apply to laod:
============
source ~/.bash_profile
Step 7:
=======
Start SonarQube
cd /opt/sonarqube/bin/linux-x86-64/
sh [Link] start