Install SonarQube 25.x (Community Edition) on Ubuntu 22.04 / 24.04
This is a complete fresh installation guide for SonarQube 25.x, using Java 17 and PostgreSQL. All commands include copy buttons for easy use.
Step 1 — Update System
sudo apt update && sudo apt upgrade -y sudo apt install -y wget unzip curl git apt-transport-https
Step 2 — Install Java 17
sudo apt install -y openjdk-17-jdk java -version
Step 3 — Install PostgreSQL
sudo apt install -y postgresql postgresql-contrib sudo systemctl enable --now postgresql
Step 4 — Create SonarQube Database & User
sudo -u postgres psql <<EOF CREATE ROLE sonaruser WITH LOGIN ENCRYPTED PASSWORD 'StrongPassword123!'; CREATE DATABASE sonarqube OWNER sonaruser ENCODING 'UTF8' LC_COLLATE='C.UTF-8' LC_CTYPE='C.UTF-8'; GRANT ALL PRIVILEGES ON DATABASE sonarqube TO sonaruser; EOF
Verify database is empty:
sudo -u postgres psql -d sonarqube -c "\dt"
Step 5 — Configure Kernel Limits (Elasticsearch)
echo "vm.max_map_count=524288" | sudo tee -a /etc/sysctl.conf echo "fs.file-max=65536" | sudo tee -a /etc/sysctl.conf sudo sysctl -p
Set user limits:
sudo tee -a /etc/security/limits.conf <<EOF sonar - nofile 65536 sonar - nproc 4096 EOF
Step 6 — Create Dedicated SonarQube User
sudo groupadd sonar sudo useradd -c "SonarQube User" -d /opt/sonarqube -g sonar -s /bin/bash sonar
Step 7 — Download SonarQube 25.x
Using your specific build: sonarqube-25.11.0.114957.zip
cd /opt sudo wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-25.11.0.114957.zip sudo unzip sonarqube-25.11.0.114957.zip sudo mv sonarqube-25.11.0.114957 sonarqube sudo chown -R sonar:sonar /opt/sonarqube
Step 8 — Configure SonarQube (sonar.properties)
sudo nano /opt/sonarqube/conf/sonar.properties
Set the following inside the file:
sonar.jdbc.username=sonaruser sonar.jdbc.password=StrongPassword123! sonar.jdbc.url=jdbc:postgresql://localhost:5432/sonarqube sonar.web.host=0.0.0.0
Step 9 — Create Systemd Service
sudo tee /etc/systemd/system/sonarqube.service > /dev/null <<EOF [Unit] Description=SonarQube 25.x Service After=network.target postgresql.service [Service] Type=forking User=sonar Group=sonar ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop Restart=always LimitNOFILE=65536 LimitNPROC=4096 Environment="JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64" [Install] WantedBy=multi-user.target EOF
sudo systemctl daemon-reload
Step 10 — Start SonarQube
sudo systemctl start sonarqube sudo systemctl enable sonarqube
Check service status:
systemctl status sonarqube
Check logs (new location for 25.x):
tail -f /opt/sonarqube/var/logs/web.log
Step 11 — Open Firewall
sudo ufw allow 9000/tcp sudo ufw status
Step 12 — Access the UI
http://YOUR_SERVER_PUBLIC_IP:9000
Default Login:
- Username: admin
- Password: admin
Installation Complete
SonarQube 25.x is now fully installed and running on your server.
No comments:
Post a Comment