Installing SonarQube on CentOS7 and Verifying Access
Overview
sonarqube is
a great tool that can aggregate code metrics for multiple languages such as
Java, Python, Ruby, and PHP.
Previously, I wrote up how to extract code metrics for the C# code of a
Unity project in a local Mac OS X environment.
This time, I have summarized below how to set it up on CentOS7.
Environment
- CentOS7 64bit
- Java 1.8
- ec2 t.micro
Installing the JDK
1 | # cd /usr/local |
1 | # tar xvf jdk-8u45-linux-x64.tar.gz |
1 | # ln -s jdk1.8.0_45 latest |
Setting the JAVA_HOME Environment Variable
Setting it in .bash_profile makes the environment variable differ per user,
so to configure it commonly for all users, place a shell script under /etc/profile.d/.
1 | # echo "export JAVA_HOME=/usr/local/java/latest |
Installing MySQL
This time, I am installing MySQL on the same server.
If you are running a separate MySQL server, this is not necessary.
1 | # yum -y install http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm |
Installing SonarQube
Get the download zip from the following site.
SonarQube Donwloads

- As of 2016-05-19, the latest is ver 5.5
1 | # mkdir /usr/local/sonarqube |
Setting the SONAR_HOME Environment Variable
1 | # echo "setenv SONAR_HOME=/usr/local/sonarqube/sonar |
Configuring SonarQube to Use MySQL
Edit the following file to configure access to the database you created.
- /usr/local/sonarqube/sonar/conf/sonar.properties
1 | sonar.jdbc.username=sonar # DB User |
Configuring the java Command Used by SonarQube
Edit the following file and change it so that the java command used by SonarQube
points to the java inside the JDK you installed.
- /usr/local/sonarqube/sonar/conf/wrapper.conf
1 | #wrapper.java.command=java |
Configuring the SonarQube Startup Script
1 | # ln -s /usr/local/sonarqube/sonar/bin/linux-x86-64/sonar.sh /etc/init.d/sonar |
Rebooting the Server
Reboot the server to apply the environment variables configured under /etc/profile.d.
1 | # reboot |
Accessing and Verifying
http://<IP address>:9000
If the SonarQube admin page is displayed, you are all set!
If You Cannot Access After Rebooting
Review the SonarQube settings, or alternatively,
with a low-memory instance like the ec2 t2.micro used here,
MySQL may crash due to insufficient memory.
Refer to the following to address it.
Afterword
In any project, there are surely many things you want to fix here and there!
At that time, rather than making a vague judgment like “this feels hard to use, so let’s fix it,”
the goal of introducing this was to be able to follow a process of first looking at
the overall state of things as numbers and making decisions based on that.
Next time, I will summarize how to run it from Jenkins.
Installing SonarQube on CentOS7 and Verifying Access
https://kenzo0107.github.io/en/2016/05/19/install-sonarqube-on-centos7/
