SonarQube is an open-source platform for continuous inspection of code quality. It detects bugs, security vulnerabilities, and code smells across 30+ programming languages. This guide installs SonarQube Community Edition on Ubuntu 26.04 LTS with PostgreSQL.
Tested and valid on:
- Ubuntu 26.04 LTS
Prerequisites
- Ubuntu 26.04 LTS with at least 2 GB RAM and 2 CPUs
- PostgreSQL installed
- Java 17 or 21 (SonarQube requirement)
- Ports 9000 open in UFW
Step 1 – Configure System Limits
sudo sysctl -w vm.max_map_count=524288
sudo sysctl -w fs.file-max=131072
echo 'vm.max_map_count=524288
fs.file-max=131072' | sudo tee /etc/sysctl.d/99-sonarqube.conf
Step 2 – Create a PostgreSQL Database
sudo -u postgres psql << 'EOF'
CREATE USER sonar WITH PASSWORD 'SonarPass2026!';
CREATE DATABASE sonardb OWNER sonar;
EOF
Step 3 – Install Java 21
sudo apt install openjdk-21-jdk -y
java -version
Step 4 – Download and Install SonarQube
SONAR_VER=10.5.1.90531
wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-${SONAR_VER}.zip -P /tmp
sudo apt install unzip -y && unzip /tmp/sonarqube-${SONAR_VER}.zip -d /opt
sudo mv /opt/sonarqube-${SONAR_VER} /opt/sonarqube
sudo useradd -r -s /bin/false sonarqube
sudo chown -R sonarqube:sonarqube /opt/sonarqube
Step 5 – Configure SonarQube
sudo nano /opt/sonarqube/conf/sonar.properties
Set:
sonar.jdbc.username=sonar
sonar.jdbc.password=SonarPass2026!
sonar.jdbc.url=jdbc:postgresql://localhost/sonardb
sonar.web.port=9000
Step 6 – Create a systemd Service
sudo nano /etc/systemd/system/sonarqube.service
Add:
[Unit]
Description=SonarQube service
After=network.target postgresql.service
[Service]
Type=forking
User=sonarqube
Group=sonarqube
ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start
ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop
Restart=on-failure
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl start sonarqube
sudo systemctl enable sonarqube
Step 7 – Access SonarQube
Visit http://your-server-ip:9000. Log in with admin / admin and change the password immediately. Configure your project and download the SonarScanner to analyse your code.
Conclusion
SonarQube is running on Ubuntu 26.04 LTS. Integrate it with Jenkins, GitLab CI, or GitHub Actions to automatically scan code quality on every commit and enforce quality gates in your CI/CD pipeline.