Monday, September 11, 2017

How to install Sonarqube on Redhat enterprise Linux - Install Sonarqube on Redhat enterprise Linux (RHEL)

SonarQube is popular static code analysis tool. It is Java based tool. Here are the steps for installing Sonarqube.

first you need to install a database as SonarQube uses database to store code quality report. We can use MySQL, Postgres, Oracle or MSSQL. Here are the steps for setting up SonarQube using MySQL database :

sudo yum update -y
sudo yum install wget -y

MySQL installation steps:
sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
sudo yum install mysql-server -y

Start MySQL service
sudo systemctl start mysqld
sudo mysql_secure_installation

enter n as we will not be setting any admin password for user root.

Would you like to setup VALIDATE PASSWORD component?
type n

now set up password for root user

Remove anonymous users?
type y
for Disallow root login remotely?
type y
for Remove test database and access to it?
type y
for Reload privileges tables
type y

Setup Sonarqube user and password

mysql -u root -p
CREATE USER 'sonar'@'localhost' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON sonar.* TO 'sonar'@'localhost';

now type exit to come out of MySQL.

Sonarqube web server installation steps:

Start with java installation.

sudo wget --no-check-certificate --no-cookies --header 'Cookie: oraclelicense=accept-securebackup-cookie' ''

sudo rpm -i jdk-8u141-linux-x64.rpm

now type java -version to make sure Java 8 is installed.

Download SonarQube
cd /opt 
sudo wget

sudo yum install unzip -y
sudo unzip
sudo mv sonarqube-6.7.6 sonarqube

Modify Sonar Conf file
sudo vi /opt/sonarqube/conf/
uncomment the below lines by removing #:

sonar.web.javaOpts=-Xmx512m -Xms256m -XX:+HeapDumpOnOutOfMemoryError
sonar.ce.javaOpts=-Xmx512m -Xms256m -XX:+HeapDumpOnOutOfMemoryError

Run Sonarqube as sonar user
create a user called sonar by executing below command:
sudo useradd sonar

sudo chown -R sonar:sonar /opt/sonarqube

Edit the start script and change the #RUN_AS_USER to be RUN_AS_USER=sonar

sudo vi /opt/sonarqube/bin/linux-x86-64/

now start the server 
sudo sh /opt/sonarqube/bin/linux-x86-64/ start
for any issues, look at logs at 

tail -f /opt/sonarqube/logs/sonar.log

Verify by going to browser http://hostname:9000



  1. A pretty detailed explanation, I'm grateful to you for sharing. Applying initially CSS; C# and PHP I wanted to go to testing the code with SonarQube

    immediately after installing Java itself. But some installation errors made me stuck up to clarify the circumstances and troubleshooting, but before I launch SonarQube, I made sure
    that my machine is running JavaVirtual and that the Java tutorials that serve me as the main source also stayed on the hard drive and are available for work. Next, following the recommendation, I paid attention to setting up the plugins, it seems like it worked well ...

  2. curl: (7) Failed to connect to port 9000: Connection refused any reason why? sonarqube is up and running