Step 1: ssh into your Linux machine
First step is to conect to your linux machine. If you are using physical linux machine, then simply open the terminal and start following the below steps. But If you are working in cloud environment, then you have to connect to your Virtual Machine using secure shell (ssh). Below is the command to connect using ssh:
ssh <username>@<hostname-or-IP-address>Step 2: Install Java
It is necessary to install Java before installing SonarQube because SonarQube, both the server and the scanners, require a Java Runtime Environment (JRE) to function. Specifically, SonarQube documentation indicates a requirement for Oracle JRE 11 or OpenJDK 11 (or later versions like Java 26 for newer SonarQube versions). Without a compatible Java installation, SonarQube will not be able to run. Here are the step to install java on your linux machine:
Update:
sudo apt updateInstall Dependencies/System Utilities:
sudo apt install wget unzip curl gnupg ca-certificates lsb-release socat -yInstall Java Runtime Environment (JRE):
sudo apt update && sudo apt install openjdk-21-jdk -yStep 3: Install PostgreSQL
Installing a supported database like PostgreSQL is a necessary prerequisite for installing and running SonarQube, especially for production environments. SonarQube requires a database to store all its data, including analysis results, project configurations, user information, and more. While SonarQube comes with an embedded H2 database for testing or demonstration purposes, it is not recommended for production use.
Securely download and store the GPG Key
sudo mkdir -p /usr/share/keyrings
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | sudo tee /usr/share/keyrings/postgresql-archive-keyring.gpg > /bin/nullAdd the repository with the locked GPG key reference:
echo "deb [signed-by=/usr/share/keyrings/postgresql-archive-keyring.gpg] http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.listUpdate packages and install a specific, modern version (e.g., PostgreSQL 16)
sudo apt update && sudo apt install postgresql-16 postgresql-contrib-16 -yEnable and start the service
sudo systemctl enable --now postgresqlOnce PostgreSQL is running, do not forget that SonarQube cannot use the default database admin account out of the box. You need to jump into PostgreSQL and create a dedicated user and schema:
sudo -u postgres psqlInside the PostgreSQL shell, run the following commands to create a user and database for SonarQube:
CREATE USER sonar WITH ENCRYPTED PASSWORD 'YourSecurePasswordHere';
CREATE DATABASE sonarqube OWNER sonar;
GRANT ALL PRIVILEGES ON DATABASE sonarqube TO sonar;
\q
Pre-Requisites on Linux Systems
Configuring the maximum number of open files and other limits. You must ensure that:
- The maximum number of memory map areas a process may have (vm.max_map_count) is greater than or equal to 524288.
- The maximum number of open file descriptors (fs.file-max) is greater than or equal to 131072.
- The user running SonarQube Server can open at least 131072 file descriptors.
- The user running SonarQube Server can open at least 8192 threads.
To check and change these limits, login as the user used to run SonarQube Server and proceed as described below depending on the type of this user.
Step 5. Install and Configure SonarQube
After installing and setting up the pre-requisites, it's time to install the SonarQube Community Edition on our Ubuntu/Debian Machine. Download the latest version of SonarQube. To find the latest version, visit the download page: https://www.sonarqube.org/downloads/
This document installs the community version. To install Enterprise (which requires licence) or other edition, visit this link: https://www.sonarsource.com/products/sonarqube/downloads/
And for more information and guidance about editions other than Community Edition, visit this official document: https://docs.sonarsource.com/sonarqube-server/server-installationDownload and install the SonarQube package:
# Download the latest stable 2026 binary zip package
wget https://sonarsource.com
# Unzip it directly to the temporary space
unzip sonarqube-2026.1.2.180529.zip
# Move the clean directory directly into place
sudo mv sonarqube-2026.1.2.180529 /opt/sonarqube
Create the System User & Apply Permissions Securely:
# Create a dedicated system service user
sudo useradd -M -d /opt/sonarqube -r -s /bin/bash sonarqube
# Grant recursive permissions over the entire workspace
sudo chown -R sonarqube:sonarqube /opt/sonarqube
Update the Database Connection Configuration:
sudo nano /opt/sonarqube/conf/sonar.propertiesFind the corresponding entries and paste these modern, optimized values. (Notice that the default PostgreSQL schema layout uses sonarqube as the database name, matching your prior database configuration):
sonar.jdbc.username=sonar
sonar.jdbc.password=YourSecurePasswordHere
sonar.jdbc.url=jdbc:postgresql://localhost:5432/sonarqube
sonar.web.host=0.0.0.0
Step 6: Add systemd services
Because you are installing SonarQube manually via a zip folder, it won't restart automatically if your server reboots. You should wrap it in a proper systemd service manager. Create a service file:
sudo nano /etc/systemd/system/sonarqube.serviceAnd paste the following content into the file:
[Unit]
Description=SonarQube service
After=syslog.target network.target postgresql.service
[Service]
Type=forking
ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start
ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop
LimitNOFILE=131072
LimitNPROC=8192
User=sonarqube
Group=sonarqube
Restart=on-failure
[Install]
WantedBy=multi-user.target
Now start the service:
sudo systemctl daemon-reload
sudo systemctl enable --now sonarqube
sudo systemctl start sonarqube
sudo systemctl status sonarqubeAllow SonarQube default port 9000 through the system's firewall:
sudo ufw allow 9000Step 7: Change Kernel Limits
As given above the pre-requisites for the linux systems, where there was a specified limits in order to install an enterprise level or other edition of SonarQube. So, here is the tutorial on how to setup the limits. Edit the sysctl configuration file to change some system defaults.
sudo nano /etc/sysctl.confAnd add the following lines to the end of the file:
vm.max_map_count=524288
fs.file-max=131072
Save and exit (Ctrl+O, Enter, Ctrl+X), then apply the changes immediately:
sudo sysctl --systemConfigure the Process Limits
sonarqube soft nofile 131072
sonarqube hard nofile 131072
sonarqube soft nproc 8192
sonarqube hard nproc 8192
verify everything is perfect:
sysctl vm.max_map_count
sysctl fs.file-max
Step 8: Access SonarQube
Go to your browser and go to the URL http://Server_IP:Port. For example: http://192.0.2.11:9000
Conclusion
You have installed SonarQube on Linux server. Login with the default credential with your username as admin and your password as admin. You can now continue and begin creating accounts for code analysis.
The credit humbly goes to the websites, from where I got help:
Official Documentation: https://docs.sonarqube.org/latest/
Other Documentation: https://docs.vultr.com/how-to-install-sonarqube-on-debian-11
Contact for personal services
Contact us for personalized assistance with your SonarQube deployment.