Install SonarQube RIGHT NOW !!

Search for a command to run...

No comments yet. Be the first to comment.
When I bought my domain jaivardhan.online, I thought the story ended there — just point the name to a server and boom, a website. But when I moved it to Cloudflare, a new word kept coming up: SSL/TLS. I had heard of HTTPS before, but I didn’t really ...

I’ve always heard words like DNS, SSL, and Cloudflare, but honestly, I didn’t really know what they meant. Recently, I bought my first domain jaivardhan.online from Hostinger, and I decided to try connecting it to Cloudflare. It turned into a fun lea...

Before we implement, you need to know the different ways to set up a Kubernetes cluster. There are 3 types in which we can create a K8s cluster , 1) Minikube 2) kubectl(the most famous and common) 3) Cloud Managed Service which is through various clo...

Before you deep dive into the article go visit docker first ! Kubernetes is just an orchestrator of containers, If you don’t know what are containers, you might feel nothing With Docker you learn: How to package an app into a container (Dockerfile)....

When I started learning Docker with a simple Spring Boot + MongoDB project, the tutor gave us two commands: # Run the Spring Boot app docker run -d -p 8080:8080 --name springapp \ --network jionetwork \ -e MONGO_DB_HOSTNAME=mongo \ -e MONGO_DB_...

You have a fresh Ubuntu instance (e.g., 22.04).
You have sudo access as your normal user.
sudo apt update
sudo apt install openjdk-17-jdk wget unzip ntp -y
Why:
openjdk-17-jdk → Java 17, required by SonarQube.
wget → to download SonarQube.
unzip → to extract the .zip.
ntp → keeps system clock synced (very important for token expiry, JWT, Elasticsearch timing).
Find which Java was installed:
update-java-alternatives -l
Output looks like:
java-1.17.0-openjdk-amd64 1711 /usr/lib/jvm/java-1.17.0-openjdk-amd64
Use the part /usr/lib/jvm/java-1.17.0-openjdk-amd64 as JAVA_HOME.
(In most Ubuntu systems installed from apt, it usually is /usr/lib/jvm/java-17-openjdk-amd64.)
Verify Java works:
java -version
Should show:
openjdk version "17.x.x"
sudo useradd -m -d /opt/sonarqube -U -r -s /bin/bash sonar
Why:
Command/Option | Meaning |
useradd | create a new user |
-m | create home directory |
-d /opt/sonarqube | set /opt/sonarqube as home directory |
-U | create a group named sonar |
-r | make this a system user (non-login user usually, but we’ll give shell) |
-s /bin/bash | assign Bash shell (so we can log in) |
sudo visudo
At the end of the file, add:
sonar ALL=(ALL) NOPASSWD:ALL

Why:
Allows sonar user to run any sudo command on any host.
NOPASSWD → no password prompt.
(handy in dev; risky in prod).
cd /opt
sudo wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-10.6.0.8109.zip
sudo unzip sonarqube-10.6.0.8109.zip
sudo mv sonarqube-10.6.0.8109/* /opt/sonarqube/
Why:
/opt is standard for optional/3rd party apps.
We move everything into /opt/sonarqube so it’s clean.
sudo chown -R sonar:sonar /opt/sonarqube
Why:
Make sure sonar user can read/write all files.
-R → recursive.
Switch to sonar user:
sudo su - sonar
Edit .bashrc:
echo 'export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64' >> ~/.bashrc
echo 'export PATH=$JAVA_HOME/bin:$PATH' >> ~/.bashrc
Then apply immediately:
source ~/.bashrc
Why:
SonarQube scripts use Java.
sonar user must know where Java is installed.
Verify:
java -version
As your main sudo user (not sonar):
sudo nano /etc/sysctl.conf
Add:
vm.max_map_count=262144
fs.file-max=65536

Apply:
sudo sysctl -p

sudo nano /etc/security/limits.conf
Add:
sonar - nofile 65536
sonar - nproc 4096

Why:
Setting | Why |
vm.max_map_count | Elasticsearch needs it; prevents memory map errors |
fs.file-max | total max open files |
nofile | max open files per user |
nproc | max processes per user |
Why: Elasticsearch uses tokens with expiry; time drift can break login or cause cluster errors.
sudo systemctl enable ntp
sudo systemctl start ntp
timedatectl status
Make sure it says NTP synchronized: yes.(if you find some error and this line means just leave that error its due to some depreciated packages)
Switch to sonar user:
sudo su - sonar
Start:
cd /opt/sonarqube/bin/linux-x86-64
./sonar.sh start
Check status:
./sonar.sh status

http://<your-server-ip>:9000
Default login:
Username: admin
Password: admin (you’ll be asked to change).

After Successful Login It prompts you to change the default password, Change it and you are good to go !
