Installing
SonarQube on Ubuntu 22.04
SonarQube is an open-source
platform for continuous code quality inspection. It allows developers and
development teams to measure and analyze code quality, identify and fix code
issues, and track code quality trends over time.
To install SonarQube on
Ubuntu 22.04, follow the steps below:
- Update your
system: sudo
apt update
- Install Java
Development Kit (JDK) if not already installed: sudo apt install
default-jdk
- Create a new
system user for SonarQube: sudo useradd -r sonarqube -d /opt/sonarqube
- Download the
latest SonarQube version from the official website:
wget
https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-x.x.zip
Replace x.x with
the desired SonarQube version.
- Extract the
downloaded file: sudo unzip sonarqube-x.x.zip -d /opt
- Change
ownership of the SonarQube directory to the newly created user: sudo chown -R
sonarqube:sonarqube /opt/sonarqube-x.x
- Configure
SonarQube to run as a service:
sudo nano
/etc/systemd/system/sonarqube.service
Add the following content to the file:
[Unit]
Description=SonarQube service After=syslog.target network.target [Service]
Type=forking ExecStart=/opt/sonarqube-x.x/bin/linux-x86-64/sonar.sh start
ExecStop=/opt/sonarqube-x.x/bin/linux-x86-64/sonar.sh stop User=sonarqube
Group=sonarqube Restart=always [Install] WantedBy=multi-user.target
- Save the
changes and close the file.
- Reload the
systemd configuration: sudo systemctl daemon-reload
- Start the
SonarQube service: sudo systemctl start sonarqube
- Enable the
SonarQube service to start on boot: sudo systemctl enable sonarqube
- Open your web
browser and access SonarQube using your server's IP address or domain
name, followed by port 9000:
http://your_server_ip:9000
- Follow the
web-based setup wizard to complete the SonarQube installation and
configuration.