How to install SonarQube on Rhel\Centos

For running SonarQube server wee need fistly instal Postgresql dabase. Instruction is here.

And now we can start to install SonarQube.

First go here https://www.sonarqube.org/downloads/ click right button on “community edition” and choose copy link.
Next we download extract and rename folder with Sonaqube.

$cd /
# wget #past here your copied link for download cummintz edition of SonarQube.
$wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-7.7.zip
$sudo unzip sonarqube-7.7.zip -d /opt
$sudo mv /opt/sonarqube-7.7 /opt/sonarqube

Create user “sonar” set password and set permission for folder with Sonarqube.

$createuser sonar
$passwd sonar
$chown sonar. /opt/sonarqube -R

Create Postgresql user

$su - postgres
$psql
$ALTER USER sonar WITH ENCRYPTED password 'My_password';
$CREATE DATABASE sonar OWNER sonar;
$\q

Set properties for Sonarqube

$sudo nano /opt/sonarqube/conf/sonar.properties

sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.jdbc.url=jdbc:postgresql://localhost:5432/sonar

$nano /opt/sonarqube/bin/linux-x86-64/sonar.sh

RUN_AS_USER=sonar

Now we can try to start our Sonarqube by following command

/opt/sonar/bin/linux-x86-64/sonar.sh start

Creating systemd service for Sonarqube

$sudo nano /etc/systemd/system/sonar.service

[Unit]
Description=SonarQube service
After=syslog.target network.target

[Service]
Type=forking
ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start
ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop
User=sonar
Group=sonar
Restart=always

[Install]
WantedBy=multi-user.target

We we enable to start Sonarqube during boot the server, start the service and check the status of Sonarqube service

$sudo systemctl enable sonar
$sudo systemctl start sonar
$sudo systemctl status sonar

Leave a Reply

Close Menu